static void Main(string[] args)
        {
            PallindromicPermutations palperm = new PallindromicPermutations();
            var          palpermres          = palperm.GeneratePalindromes("aba");
            Permutations pra           = new Permutations();
            var          upperandlower = pra.GetPermutationsUpperAndLower(new char[] { 'h', 'a', 't' });


            StringArrayPermutation spa = new StringArrayPermutation();
            var rspa = spa.GetStringPermutations(new string[] { "red", "fox", "super" });

            EnglishToIntegerWords etoi = new EnglishToIntegerWords();
            string pronoune            = etoi.NumberToWords(2147483647);

            LongestWordFromOtherWords lw = new LongestWordFromOtherWords();

            string[] longestWords = new string[] { "dog", "cat", "walk", "e", "nana", "dogwalker", "banana", "ba" };
            string   lword        = lw.Longest(longestWords);

            //string xyz = TileCase("hello world");



            //PreorderSerialization pre = new PreorderSerialization();
            //bool what = pre.IsValidSerialization(@"531###78##10##");

            //WordPatternProblem wp = new WordPatternProblem();
            //bool j= wp.WordPattern("abba", "dog cat cat dog");

            //Combinations co = new Combinations();
            //var csa = co.PrintAllCombinationsDuplicates(new int[] { 1, 1, 1, 1 });

            Permutations p  = new Permutations();
            var          l  = p.GetPermutations(new int[] { 1, 2, 3, 4 });
            var          l1 = p.GetPermutationsDuplicates(new int[] { 1, 2 });
            string       a  = "  hello  wor ld";

            string[]  tok = a.Split(' ');
            MyStrings s   = new MyStrings();
            //string rev = s.Reverse("              the   sky  blue");

            ISet <string> set = new HashSet <string>();

            set.Add("hot");
            set.Add("dot");
            set.Add("dog");
            set.Add("lot");
            set.Add("log");
            set.Add("fog");
            //set.Add("fot");

            //WordLadderProblem ladder = new WordLadderProblem();
            //int l =  ladder.GetShortestPath("hot", "dog",set);

            //WordLadderProblem2 ladder2 = new WordLadderProblem2();
            //var res = ladder2.GetWordLadderPath2("hit", "cog", set);


            char[,] matrix = new char[3, 4]
            {
                { 'A', 'B', 'C', 'E' },
                { 'S', 'F', 'C', 'S' },
                { 'A', 'D', 'E', 'E' }
            };


            WordSearch ws = new WordSearch();

            //bool a = ws.WordExists(matrix, "ABCCED");

            char[,] matrix2 = new char[4, 4]
            {
                { 'o', 'a', 'a', 'n' },
                { 'e', 't', 'a', 'e' },
                { 'i', 'h', 'k', 'r' },
                { 'i', 'f', 'l', 'v' }
            };

            string[] dic = new string[]
            {
                "oath", "pea", "eat", "rain", "neat"
            };

            WordSearch2 ws2 = new WordSearch2();
            // var res = ws2.FindDictionaryWords(matrix2, dic);

            OneEditDistanceAway oed = new OneEditDistanceAway();
            //bool test = oed.IsOneEditDistance("abcd", "abcdefg");

            Anagrams ana = new Anagrams();
            //ana.GroupStrings(new string[] { "abc", "bcd", "acef", "xyz", "az", "ba", "a", "z" });

            // Pallindrome p = new Pallindrome();
            //var sp = p.ShortestPalindrome("aabba");
            // Console.ReadLine();

            PhoneNumberWords ph         = new PhoneNumberWords();
            HashSet <string> validWords = new HashSet <string>()
            {
                "money", "tree", "used", "cab", "bac", "ped", "red"
            };

            ph.GetValidWordsFromDigits("733", validWords);

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            StepsJumpWays sj   = new StepsJumpWays();
            var           ways = sj.PrintWaysToReachNsteps(4);

            SubsetSum      subsum     = new SubsetSum();
            bool           hasmel     = subsum.SubSetSumExists(new int[] { 1, 4, 5, 2, 3 /*5, 3, 2, 7 */ }, 6, 2);
            PerfectSquares ps         = new PerfectSquares();
            int            numsq      = ps.NumSquares(16);
            DecodeWays     dw         = new DecodeWays();
            int            dwways     = dw.NumDecodings("1234");
            JumpGame       jump       = new JumpGame();
            int            leastJumps = jump.Jump(new int[] { 4, 1, 1, 3, 1, 1, 1 });
            WordPAttern    wpa        = new WordPAttern();
            bool           fgh        = wpa.WordPatternMatch("aba", "wxyzwx");

            PaintHouses pho = new PaintHouses();

            int[,] costs = new int[, ]
            {
                { 4, 16 },
                { 15, 5 },
                { 18, 7 }
            };
            int    costs_min = pho.MinCostII(costs);
            Regex2 rgx       = new Regex2();
            bool   mat       = rgx.IsMatch("aaba", "a*");

            //WordPattern2 wp2 = new WordPattern2();
            //bool matches = wp2.PatternMatches("dogcatcatdog", "abba");

            HistogramArea ha = new HistogramArea();
            //int answer = ha.LargestRectangleArea(new int[] { 2, 1, 2, 3, 1 });

            MaxSquareAllOnes msq = new MaxSquareAllOnes();

            char[,] input = new char[, ] {
                { '1', '0' }
            };
            // int xam =  msq.MaximalSquare(input);
            RegularExpressionMatching rex = new RegularExpressionMatching();
            string text    = "aaba";
            string pattern = @"ab*a*c*a";
            bool   rexx    = rex.IsMatch(text, pattern);

            PointsInGrid pg = new PointsInGrid();

            int[,] pgrid = new int[, ]
            {
                { 1, 3, 1 },
                { 1, 5, 1 },
                { 4, 2, 1 }
            };

            var w = pg.MinPathSum(pgrid);

            LongestIncreasingPathProblem lip = new LongestIncreasingPathProblem();

            int[,] pa = new int[, ]
            {
                { 9, 9, 4 },
                { 6, 6, 8 },
                { 2, 1, 1 }
            };

            //int x  = lip.LongestIncreasingPath(pa);


            WordSearch ws = new WordSearch();

            string[] di = new string[] { "pea", "oath", "eat", "rain" };

            char[,] puzz = new char[, ]
            {
                { 'o', 'a', 'a', 'n' },
                { 'e', 't', 'a', 'e' },
                { 'i', 'h', 'k', 'r' },
                { 'i', 'f', 'l', 'v' }
            };
            var bag = ws.FindDictionaryWords(puzz, di);



            Combinations cb1 = new Combinations();
            //         cb1.Subsets(new int[] { 1, 2 ,3});

            CoinChange c = new CoinChange();

            int[] Coins = new int[] { 3, 1, 2, 4, 5 };

            int[] Coins2 = new int[] { 1, 2, 5 };
            //var res = c.MinCoinsForSum(Coins2, 11);
            // int numberOfWays = c.CombinationSum(Coins, 4);

            Combinations comb = new Combinations();
            //var res = comb.UniqueCombinationsSum(Coins,2);

            //var  res = comb.UniqueCombinationsSumNoRepeat(new int[] {1,1,2,5},8);

            //var res = comb.UniqueCombinationsKNumbersSumToN(2, 5);

            RobotProblem rb = new RobotProblem();

            int[,] robotPath = new int[3, 4]
            {
                { 1, 1, 1, -1 },
                { 1, -1, 1, -1 },
                { 1, 1, 1, 1 }
            };

            //var paths = rb.NumberOfUniquePaths(robotPath);
            //rb.PrintAllPaths(paths);

            // int[,] islandOperations = new int[,]
            //{{0,1},{1,2},{2,1},{1,0},{0,2},{0,0},{1,1}};



            //Island land = new Island();
            //land.NumIslands2(3, 3, islandOperations);

            char[,] island = new char[, ]
            {
                { '1', '1', '1', '1', '0' },
                { '1', '1', '0', '1', '0' },
                { '1', '1', '0', '0', '0' },
                { '0', '0', '0', '0', '0' }
            };
            //{["11110", "11010", "11000", "00000"];

            Islands2 is2 = new Islands2();
            int      d   = is2.NumIslands(island);

            //var r = rb.NumberOfUniquePathsDP(robotPath);



            int[]    a = new int[] { 100, 4, 200, 1, 3, 2, 5, 3, 4 };
            Solution s = new Solution();

            // var l = s.LongestConsecutive(a);

            //char[,] puzzle = new char[,]
            //{
            //    {'5','3','.','.','7','.','.','.','.' },
            //    { '6','.','.','1','9','5','.','.','.'},
            //    { '.','9','8','.','.','.','.','6','.'},
            //    { '8','.','.','.','6','.','.','.','3'},
            //    {'5','3','.','.','7','.','.','.','.' },
            //    {'4','.','.','8','.','3','.','.','1' },
            //    {'7','.','.','.','2','.','.','.','6' },
            //    {'.','6','.','.','.','.','2','8','.' },
            //    {'.','.','.','4','1','9','.','.','5' },
            //    {'.','.','.','.','8','.','.','7','9' }
            //};

            //   ["..4...63.",".........","5......9.","...56....","4.3.....1","...7.....","...5.....",".........","........."]

            char[,] puzzle = new char[, ]
            {
                { '.', '.', '4', '.', '.', '.', '6', '3', '.' },
                { '.', '.', '.', '.', '.', '.', '.', '.', '.' },
                { '5', '.', '.', '.', '.', '.', '.', '9', '.' },
                { '.', '.', '.', '5', '6', '.', '.', '.', '.' },

                { '4', '.', '3', '.', '.', '.', '.', '.', '1' },

                { '.', '.', '.', '7', '.', '.', '.', '.', '.' },

                { '.', '.', '.', '5', '.', '.', '.', '.', '.' },
                { '.', '.', '.', '.', '.', '.', '.', '.', '.' },
                { '.', '.', '.', '.', '.', '.', '.', '.', '.' },
            };
            Sudoko sd = new Sudoko();
            //var yes = sd.IsValidSudoku(puzzle);

            PhoneNumbers ph = new PhoneNumbers();
            var          l  = ph.GetLetterCombinations("222");

            Console.ReadLine();
        }