Example #1
0
        public LeetCode()
        {
            Solution1 s = new Solution1();

            Console.WriteLine("Result : (" + s.Convert("PAYPALISHIRING", 3) + ")");
            s = new Solution1();
            Console.WriteLine("Result : (" + s.Convert("PAYPALISHIRING", 4) + ")");
            s = new Solution1();
            Console.WriteLine("Result : (" + s.Convert("PAYPALISHIRING", 1) + ")");

            Solution2 s2 = new Solution2();

            Console.WriteLine("Result : " + s2.Reverse(-123));
            s2 = new Solution2();
            Console.WriteLine("Result : " + s2.Reverse(56789));
            s2 = new Solution2();
            Console.WriteLine("Result : " + s2.Reverse(120));
            s2 = new Solution2();
            Console.WriteLine("Result : " + s2.Reverse(1534236469)); //this output is wrong, but i don't know why

            Solution3 s3 = new Solution3();

            Console.WriteLine("Result : " + s3.LongestPalindrome("babad"));
            Console.WriteLine("Result : " + s3.LongestPalindrome("a"));
            Console.WriteLine("Result : " + s3.LongestPalindrome("cbbd"));
        }
Example #2
0
        static void Main()
        {
            var solution = new Solution2();

            int[,] grid = new int[, ]
            {
                { 0, 1, 1, 0, 1 },
                { 0, 1, 0, 1, 0 },
                { 0, 0, 0, 0, 1 },
                { 0, 1, 0, 0, 0 },
            };
            solution.minimalDays(4, 5, grid);
        }
Example #3
0
        public static void createProjectsFromTemplates(EnvDTE.DTE dte, string filename)
        {
            try
            {
                // Create a solution with two projects in it, based on project
                // templates.
                Solution2 soln = (Solution2)dte.Solution;
                //= "abcd";
                string csTemplatePath;
                string csPrjPath = string.Format("C:\\Downloads\\DB\\MyDBProject\\{0}", Path.GetFileName(filename).Replace("dacpac", ""));
                // Get the project template path for a C# console project.
                // Console Application is the template name that appears in
                // the right pane. "CSharp" is the Language(vstemplate) as seen
                // in the registry.
                csTemplatePath = soln.GetProjectTemplate("SSDT.vstemplate", "Database");

                //System.Windows.Forms.MessageBox.Show("SQL template path: " + csTemplatePath);

                // Create a new C# console project using the template obtained
                // above.
                Project prj = soln.AddFromTemplate(csTemplatePath, csPrjPath, Path.GetFileName(filename).Replace("dacpac", ""), false);

                string commandArg = string.Format(CultureInfo.InvariantCulture,
                                                  "/FileName {0} " +
                                                  "/GroupByType " +
                                                  "/GroupBySchema", filename);

                System.Threading.Thread.Sleep(1000 * 10);

                dte.ExecuteCommand("Project.SSDTImportDac", commandArg);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
            }
        }