Ejemplo n.º 1
0
        public void ToLowerCaseTestMethod()
        {
            ToLowerCase toLowerCase = new ToLowerCase();
            var         expected1   = "hello";
            var         input1      = "Hello";

            Assert.AreEqual(expected1, toLowerCase.ToLower(input1));

            var expected2 = "here";
            var input2    = "here";

            Assert.AreEqual(expected2, toLowerCase.ToLower(input2));

            var expected3 = "lovely";
            var input3    = "LOVELY";

            Assert.AreEqual(expected3, toLowerCase.ToLower(input3));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            #region 1. Two Sum

            TwoSums twoSums = new TwoSums(new int[] { 2, 7, 11, 15 }, 18);
            twoSums.PrintExample();

            #endregion

            #region 3. LongestSubstringWithoutRepeatingCharacters

            LongestSubstringWithoutRepeatingCharacters longestSubstringWithoutRepeating = new LongestSubstringWithoutRepeatingCharacters("abcdecb");
            longestSubstringWithoutRepeating.PrintExample();

            #endregion

            #region 7. Reverse Integer

            ReverseInteger reverseInteger = new ReverseInteger(-54321);
            reverseInteger.PrintExample();

            #endregion

            #region 8. String to Integer (atoi)

            StringToInteger stringToInteger = new StringToInteger("  -42");
            stringToInteger.PrintExample();

            #endregion

            #region 9. Palindrome Number

            PalindromeNumber palindromeNumber = new PalindromeNumber(121);
            palindromeNumber.PrintExample();

            #endregion

            #region 20. Valid Parentheses

            ValidParentheses validParentheses = new ValidParentheses("(){[]}");
            validParentheses.PrintExample();

            #endregion

            #region 26. Remove Duplicates from Sorted Array

            RemoveDuplicatesFromSortedArray removeDuplicatesFromSortedArray = new RemoveDuplicatesFromSortedArray(new [] { 1, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 6 });
            removeDuplicatesFromSortedArray.PrintExample();

            #endregion

            #region 35. Search Insert Position

            SearchInsertPosition searchInsertPosition = new SearchInsertPosition(new [] { 1, 3, 5, 10 }, 9);
            searchInsertPosition.PrintExample();

            #endregion

            #region 58. Length of Last Word

            LengthOfLastWord lengthOfLastWord = new LengthOfLastWord("Hello World");
            lengthOfLastWord.PrintExample();

            #endregion

            #region 104. Maximum Depth of Binary Tree



            #endregion

            #region 125. Valid Palindrome

            ValidPalindrome validPalindrome = new ValidPalindrome("A man, a plan, a canal: Panama");
            validPalindrome.PrintExample();

            #endregion

            #region 136. Single Number

            SingleNumber singleNumber = new SingleNumber(new [] { 2, 2, 3, 3, 1 });
            singleNumber.PrintExample();

            #endregion

            #region 150. Evaluate Reverse Polish Notation

            EvaluateReversePolishNotation evaluateReversePolishNotation = new EvaluateReversePolishNotation(new [] { "2", "1", "+", "3", "*" });
            evaluateReversePolishNotation.PrintExample();

            #endregion

            #region 155. Min Stack

            MinStack minStack = new MinStack();
            minStack.PrintExample();

            #endregion

            #region 167. Two Sum II - Input array is sorted

            TwoSumII twoSumII = new TwoSumII(new [] { 1, 2, 3, 7 }, 10);
            twoSumII.PrintExample();

            #endregion

            #region 200. Number of Islands

            NumberOfIslands numberOfIslands = new NumberOfIslands(new char[, ]
            {
                { '1', '1', '0', '0', '0' },
                { '1', '1', '0', '0', '0' },
                { '0', '0', '1', '0', '0' },
                { '0', '0', '0', '1', '1' }
            });
            numberOfIslands.PrintExample();

            #endregion

            #region 217. Contains Duplicate

            ContainsDuplicate containsDuplicate = new ContainsDuplicate(new [] { 1, 2, 3, 1 });
            containsDuplicate.PrintExample();

            #endregion

            #region 268. Missing Number

            MissingNumber missingNumber = new MissingNumber(new [] { 9, 6, 4, 2, 3, 5, 7, 0, 1 });
            missingNumber.PrintExample();

            #endregion

            #region 344. Reverse String

            ReverseString reverseString = new ReverseString("A man with a plan");
            reverseString.PrintExample();

            #endregion

            #region 387. First Unique Character in a String

            FirstUniqueCharacterInAString firstUniqueChar = new FirstUniqueCharacterInAString("loveleetcode");
            firstUniqueChar.PrintExample();

            #endregion

            #region 412. FizzBuzz

            FizzBuzz fizzBuzz = new FizzBuzz(15);
            fizzBuzz.PrintExample();

            #endregion

            #region 485. Max Consecutive Ones

            MaxConsecutiveOnes maxConsecutiveOnes = new MaxConsecutiveOnes(new int[] { 1, 1, 0, 1, 1, 1 });
            maxConsecutiveOnes.PrintExample();

            #endregion

            #region 509. Fibonacci Number

            FibonacciNumber fibonacciNumber = new FibonacciNumber(10);
            fibonacciNumber.PrintExample();

            #endregion

            #region 622. Design Circular Queue

            CircularQueue circularQueue = new CircularQueue(1);
            Console.WriteLine("622. Design Circular Queue");
            Console.WriteLine($"Front()   : {circularQueue.Front()}");
            Console.WriteLine($"IsEmpty() : {circularQueue.IsEmpty()}");
            circularQueue.EnQueue(1);
            Console.WriteLine($"EnQueue(1)");
            Console.WriteLine($"IsEmpty() : {circularQueue.IsEmpty()}");
            Console.WriteLine($"IsFull()  : {circularQueue.IsFull()}\n");

            #endregion

            #region 707. Design Linked List

            LinkedList linkedList = new LinkedList(new Node());
            linkedList.AddAtTail(10);
            linkedList.AddAtTail(20);
            linkedList.PrintLinkedList();

            #endregion

            #region 709. To Lower Case

            ToLowerCase toLowerCase = new ToLowerCase("LOVELY");
            toLowerCase.PrintExample();

            #endregion

            #region 739. Daily Temperatures

            DailyTemperatures dailyTemperatures = new DailyTemperatures(new [] { 89, 62, 70, 58, 47, 47, 46, 76, 100, 70 });
            dailyTemperatures.PrintExample();

            #endregion

            #region 747. Largest Number at Least Twice of Others

            LargestNumberAtLeastTwiceOfOthers largestNumberAtLeastTwiceOfOthers = new LargestNumberAtLeastTwiceOfOthers(new [] { 3, 6, 1, 0 });
            largestNumberAtLeastTwiceOfOthers.PrintExample();

            #endregion

            #region 771. Jewels and Stones
            string          j = "aA", s = "aAAbbbb";
            JewelsAndStones jewelsAndStones = new JewelsAndStones(j, s);
            jewelsAndStones.PrintExample();

            #endregion

            #region 832. Flipping an Image
            int[][] flippingImageArray      = new int[3][];
            flippingImageArray[0] = new int[] { 1, 1, 0 };
            flippingImageArray[1] = new int[] { 1, 0, 1 };
            flippingImageArray[2] = new int[] { 0, 0, 0 };
            FlippingAnImage flippingAnImage = new FlippingAnImage(flippingImageArray);
            flippingAnImage.PrintExample();

            #endregion

            #region 917. Reverse Only Letters

            ReverseOnlyLetters reverseOnlyLetters = new ReverseOnlyLetters("Qedo1ct-eeLg=ntse-T!");
            reverseOnlyLetters.PrintExample();

            #endregion


            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public void SelectedTextToLower()
        {
            var action = new ToLowerCase();

            action.Execute(editorBox.ActiveTextAreaControl.TextArea);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //FindUniqueCharacter fuc = new FindUniqueCharacter();

            //Console.WriteLine(fuc.FindUniqueCharacterFromString("abcda"));
            //Console.WriteLine(fuc.FindUniqueCharacterFromStringWithoutDS("abcda"));


            //PalindromePermutation pp = new PalindromePermutation();
            //Console.WriteLine(pp.Permutation("abbccda"));

            //StringRotation sr = new StringRotation();
            //Console.WriteLine(sr.IsSubstring("waterbottle", "erbottlewas"));

            //ReverseWordsInAString rw = new ReverseWordsInAString();
            //Console.WriteLine(rw.ReverseWords("My name is Yash"));

            //PermutationsOfString ps = new PermutationsOfString();
            //ps.StringPermutations("ABC");

            ////LongestPalindromicSubsequence lps = new LongestPalindromicSubsequence();
            ////Console.WriteLine(lps.LongestSubsequencePalindrome("aaaabbaa"));

            //FirstNonRepeatingCharacter frc = new FirstNonRepeatingCharacter();
            //Console.WriteLine(frc.NonRepeatingCharacter("hello"));

            //LongestCommonSubstring lcs = new LongestCommonSubstring();
            //Console.WriteLine(lcs.LongestSubstringCommon("abcvdefgh","bqdrcvefgh"));

            //CheckForAnagram ca = new CheckForAnagram();
            //Console.WriteLine(ca.IsAnagram("cat", "tac"));

            //ReverseString rs = new ReverseString();
            //Console.WriteLine(rs.ReverseStringUsingIteration("Yash"));
            //Console.WriteLine(rs.ReverseStringUsingRecursion("Yash"));

            //ReverseCharactersInString rc = new ReverseCharactersInString();
            //Console.WriteLine(rc.ReverseCharacters("My name is Yash"));

            //CombinationOfSubsetOfSizeK cs = new CombinationOfSubsetOfSizeK();
            //cs.SubsetOfSizeK(new int[] {1,4,3,2,5}, 4);

            //SubsetsOfSizeK ssk = new SubsetsOfSizeK();
            //ssk.SubsetsOfK(new char[] { 'a', 'b', 'c', 'd', 'e' }, 4);

            //RotateMatrix rm = new RotateMatrix();
            //int[,] matrix = rm.RotateMatrixAntiClockWise(new int[,] { { 1,2,3,4}, { 5,6,7,8}, { 9,10,11,12}, { 13,14,15,16} });

            //for (int i = 0; i < matrix.GetLength(0); i++)
            //{
            //    for (int j = 0; j < matrix.GetLength(1); j++)
            //    {
            //        Console.Write(matrix[i, j] + " ");
            //    }

            //    Console.WriteLine(' ');
            //}

            //rm.RotateMatrixUsingTranspose(new int[,] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 } }, 4);

            ////SinglyLinkedList sll = new SinglyLinkedList();


            ////ListNode ls = sll.CreateLinkedList();

            ////sll.DisplayList(ls);
            ////Console.WriteLine("\nCount -> {0}", sll.GetCountIterative(ls));

            ////Console.WriteLine("\nCount -> {0}", sll.GetCountRecursive(ls));

            ////Console.WriteLine("\n3rd Node from End -> {0}", sll.NthNodeFromEnd(ls, 1));

            ////Console.WriteLine("\nMiddle Element -> {0}", sll.FindMiddleOfList(ls));

            ////ls = sll.DeleteNode(ls, 10);
            ////sll.DisplayList(ls);

            ////FindFirstandLastPositionofElementinSortedArray ffl = new FindFirstandLastPositionofElementinSortedArray();
            ////Console.WriteLine(ffl.SearchRange(new int[] {1,2,3,4,5,6,6,6,6,6},6));

            //CreateBinaryTree cbt = new CreateBinaryTree();
            //BinaryTree bt = cbt.CreateBTree();

            ToLowerCase tlc = new ToLowerCase();

            Console.WriteLine(tlc.ToLowerCaseString("Yash"));

            FlippinganImage fai = new FlippinganImage();

            int[,] array = fai.FlipAndInvertImage(new int[, ] {
                { 1, 1, 0 }, { 1, 0, 1 }, { 0, 0, 0 }
            });

            for (int i = 0; i < array.GetLength(0); i++)
            {
                for (int j = 0; j < array.GetLength(1); j++)
                {
                    Console.Write(array[i, j]);
                }
                Console.WriteLine();
            }

            SingleNumberIII sn = new SingleNumberIII();

            int[] a = sn.SingleNumber(new int[] { 1, 2, 1, 3, 2, 5 });

            SlidingWindowMaximum swm = new SlidingWindowMaximum();

            a = swm.MaxSlidingWindow(new int[] { 1, 3, -1, -3, 5, 3, 6, 7 }, 3);

            Console.ReadLine();
        }