Inheritance: MonoBehaviour
Example #1
0
        public void ContainOnlyOneElementAtTheEnd()
        {
            var re     = new RemoveElement();
            var list   = new int[] { 4, 5 };
            var result = re.RemoveElem(list, 5);

            Assert.AreEqual(1, result);
        }
Example #2
0
        public void ListIsEmpty()
        {
            var re     = new RemoveElement();
            var list   = new int[] { };
            var result = re.RemoveElem(list, 3);

            Assert.AreEqual(0, result);
        }
Example #3
0
        public void ContainOnlyElement()
        {
            var re     = new RemoveElement();
            var list   = new int[] { 3, 3 };
            var result = re.RemoveElem(list, 3);

            Assert.AreEqual(0, result);
        }
Example #4
0
        public void ContainElement()
        {
            var re     = new RemoveElement();
            var list   = new int[] { 3, 2, 3, 6, 4, 5 };
            var result = re.RemoveElem(list, 3);

            Assert.AreEqual(4, result);
        }
Example #5
0
        public void DoesNotContainElement()
        {
            var re     = new RemoveElement();
            var list   = new int[] { 3, 2, 3, 6, 4, 5 };
            var result = re.RemoveElem(list, 1);

            Assert.AreEqual(list.Count(), result);
        }
Example #6
0
        public void RemoveElementSolution()
        {
            var nums      = new[] { 3, 2, 2, 3 };
            var val       = 3;
            var testClass = new RemoveElement();
            var res       = testClass.Solution(nums, val);

            Assert.AreEqual(2, res);
        }
Example #7
0
        public void ContainOnlyOneElementAtTheBeginning()
        {
            //comment

            var re     = new RemoveElement();
            var list   = new int[] { 4, 5 };
            var result = re.RemoveElem(list, 4);

            Assert.AreEqual(1, result);
        }
        public void Excution1Test()
        {
            var func = new RemoveElement();

            Assert.AreEqual(2, func.Excution1(new int[] { 3, 2, 2, 3 }, 3));

            Assert.AreEqual(5, func.Excution1(new int[] { 0, 1, 2, 2, 3, 0, 4, 2 }, 2));

            Assert.AreEqual(5, func.Excution1(new int[] { 0, 0, 2, 2, 3, 0, 4, 2 }, 0));

            Assert.AreEqual(4, func.Excution1(new int[] { 0, 0, 2, 2, 3, 0, 2, 2 }, 2));
        }
        public void SimpleTest_EasyRemove2()
        {
            //Given
            var nums = new int[8] {
                0, 1, 2, 2, 3, 0, 4, 2
            };

            //When
            var result = new RemoveElement().Go(nums, 2);

            //Then
            Assert.Equal(5, result);
        }
        public void SimpleTest_EasyRemove()
        {
            //Given
            var nums = new int[4] {
                3, 2, 2, 3
            };

            //When
            var result = new RemoveElement().Go(nums, 3);

            //Then
            Assert.Equal(2, result);
            Assert.Equal(2, nums[0]);
            Assert.Equal(2, nums[1]);
        }
Example #11
0
        public void RemoveElementSlnTestMethod()
        {
            var removeElement = new RemoveElement();
            var input_nums1   = new int[] { 3, 2, 2, 3 };
            var input_val1    = 3;
            var expected1     = 2;
            var actual1       = removeElement.RemoveElementSln(input_nums1, input_val1);

            Assert.AreEqual(expected1, actual1);

            var input_nums2 = new int[] { 0, 1, 2, 2, 3, 0, 4, 2 };
            var input_val2  = 2;
            var expected2   = 5;
            var actual2     = removeElement.RemoveElementSln(input_nums2, input_val2);

            Assert.AreEqual(expected2, actual2);

            var input_nums3 = new int[] { };
            var input_val3  = 2;
            var expected3   = 0;
            var actual3     = removeElement.RemoveElementSln(input_nums3, input_val3);

            Assert.AreEqual(expected3, actual3);

            var input_nums4 = new int[] { 2, 2, 2, 2, 2, 2, 2, 2 };
            var input_val4  = 2;
            var expected4   = 0;
            var actual4     = removeElement.RemoveElementSln(input_nums4, input_val4);

            Assert.AreEqual(expected4, actual4);

            var input_nums5 = new int[] { 2 };
            var input_val5  = 3;
            var expected5   = 1;
            var actual5     = removeElement.RemoveElementSln(input_nums5, input_val5);

            Assert.AreEqual(expected5, actual5);

            var input_nums6 = new int[] { 3, 3 };
            var input_val6  = 5;
            var expected6   = 2;
            var actual6     = removeElement.RemoveElementSln(input_nums6, input_val6);

            Assert.AreEqual(expected6, actual6);
        }
Example #12
0
 private void OnElementRemove(Guid guid)
 {
     RemoveElement?.Invoke(guid);
 }
Example #13
0
        public int RemoveElement(int[] nums, int val)
        {
            var removeElement = new RemoveElement(nums, val);

            return(removeElement.SolutionOne());
        }
Example #14
0
        static void Main(string[] args)
        {
            SortedMatrixSearch.Run();
            SparseSearch.Run();
            SearchInRotatedArray.Run();
            GroupAnagrams.Run();
            CombinationsOfNPairsParentheses.Run();
            PermutationWithDuplicates.Run();
            PermutationNoDuplicates.Run();

            var subsetList = new List <List <int> >();

            subsetList = SubsetInSet.FindAllSubsetInSet(new List <int> {
                1, 2, 3
            });
            ReverseLinkedList.Run();
            IsUniqueString.Run();
            StoneDivisionProblem.Run();
            Kangaroo.Run();
            AppleAndOrange.Run();
            AbbreviationProblem.Run();
            FibonacciModifiedProblem.Run();
            RecursiveDigitSum.Run();
            RangeSumOfBST.Run();
            GradingStudentsProblem.Run();
            // XorSequenceProblem.Run();
            CounterGameProblem.Run();
            MaximizingXORProblem.Run();
            LonelyIntegerProblem.Run();
            FlippingBitsProblem.Run();
            QueueUsingTwoStacksProblem.Run();
            GetNodeValue.Run();
            MergeTwoSortedLinkedLists.Run();
            Compare_Two_linked_lists.Run();

            DeleteNodeProblem.Run();
            ArrayManipulationProblem.Run();
            LeftRotationProblem.Run();
            HourGlass2D.Run();
            SimpleTextEditorProblem.Run();
            EqualStacksProblem.Run();
            MaximumElementProblem.Run();
            BinarySearchTreeInsertion.Run();
            TopViewProblem.Run();
            TimeConvertsionProblem.Run();
            BinaryTreePathsProblem.Run();
            IncreasingOrderSearchTree.Run();
            RemoveAllAdjacentDuplicatesInStringWithKLength.Run();
            RemoveAllAdjacentDuplicatesInString.Run();
            CheckStraightLineProblem.Run();
            HouseRobber.Run();
            UniquePathsProblem.Run();
            FirstUniqueCharacterInString.Run();
            BinaryTreeInorderTraversal.Run();
            DailyTemperaturesProblem.Run();
            CountingBitsproblem.Run();
            SortIntegersByTheNumberOf1BitsProblem.Run();
            HammingDistanceProblem.Run();
            RansomNoteProblem.Run();
            ConvertBinaryNumberInLinkedListToIntegerProblem.Run();
            NumberOfStepsToReduceNumberToZeroProblem.Run();
            JewelsAndStones.Run();
            ClimbingStairsProblem.Run();
            BestTimeToBuyAndSellStock.Run();
            MajorityElementProblem.Run();
            MoveZeroesProblem.Run();
            InvertBinaryTree.Run();
            SingleNumberProblem.Run();
            MaximumDepthInTrree.Run();
            MergeTwoBinaryTrees.Run();
            AddBinaryProblem.Run();
            PlusOneProblem.Run();
            LengthOfLastWordProblem.Run();
            KadaneAlgorithmForMaxSubArray.Run();
            KMPAlgorithm.Run();
            CountAndSayProblem.Run();
            SearchInsertPosition.Run();
            ImplementIndexOfString.Run();
            RemoveElement.Run();
            RemoveDuplicatesFromSortedArray.Run();
            MergeTwoSortedLists.Run();
            ValidParentheses.Run();
            LongestCommonPrefix.Run();
            RomanToInteger.Run();
            PalindromeNumber.Run();
            ReverseInteger.Run();
            TwoSumProblem.Run();
            AddOneToNumber.Run();
            MostAmountOfChange.Run();
            #region BinaryTree
            LeastCommonAncestor.Run();
            PrintAllPaths.Run();
            HasPathSum.Run();
            CheckIfBinaryTreeIsBinarySearchTree.Run();
            PrintAllNodesWithRangeInBinarySearchTree.Run();
            UniqueTreeStructureNumber.Run();
            MirrorTree.Run();
            #region BitManuiplation_GetNthNumber
            NumberOfStepsToReduceNumberToZeroProblem.Run();
            CountNumbersOf1InBit.Run();
            ReverseThebitsInInteger.Run();
            PrintBitsInInteger.Run();
            GetNthBit.Run();
            setNthBitTo1.Run();
            SetNthBitTo0.Run();
            #endregion
            MinimumtValueInTrree minValueInTree = new MinimumtValueInTrree();
            minValueInTree.Run();
            #endregion

            #region Recursion
            Chessboard chessboard = new Chessboard();
            chessboard.Run();
            RatPathToMaze ratPathToMaze = new RatPathToMaze();
            ratPathToMaze.Run();
            List <string> anagramList = new List <string>();
            anagramList        = WordAnagram.GenerateWordAnagram("abc");
            Pixel[,] pixelList = new Pixel[3, 3] {
                { new Pixel(0, 0, "red"), new Pixel(0, 1, "green"), new Pixel(0, 2, "green") },
                { new Pixel(1, 0, "red"), new Pixel(1, 1, "green"), new Pixel(1, 2, "green") },
                { new Pixel(2, 0, "red"), new Pixel(2, 1, "green"), new Pixel(2, 2, "green") }
            };
            FillPaint.PaintFill(pixelList, 1, 2, "green", "black");

            BinaryTreesAreTheSame.Run();

            #endregion

            #region General problems
            RotateArrayByKSpaces.Run();

            #region AddtwoNumbersReferencedByTheirDigits
            var addRes = AddtwoNumbersReferencedByTheirDigits.AddNumbers(new int[] { 1, 2, 7 }, new int[] { 9, 4 });
            #endregion

            #region RunLengthEncoding
            var encodedStr = RunLengthEncoding.Encode("aabbbbc");
            var decodedStr = RunLengthEncoding.Decode(encodedStr);
            #endregion

            #region BreakDocumentIntoChunk
            var chunkRes = BreakDocumentIntoChunk.Chunkify("ab:dd:ddfcct:aab:cccc", ':', 5);
            #endregion

            #region GameOfLife
            var gameRes = GameOfLife.GetNextInteration(new int[3, 3] {
                { 1, 0, 0 }, { 0, 1, 1 }, { 1, 0, 0 }
            });
            #endregion .

            #endregion


            #region InsertionSort
            InsertionSort.insertionSort(listToSort);
            #endregion

            #region BinarySearch
            Console.WriteLine(String.Format("%s is present at index: %s", 30, BinarySearch.binarySearch(sortedArray, 30, 0, sortedArray.Length - 1)));
            Console.WriteLine(String.Format("%s is present at index: %s", 4, BinarySearch.binarySearch(sortedArray, 4, 0, sortedArray.Length - 1)));
            Console.WriteLine(String.Format("%s is present at index: %s", 15, BinarySearch.binarySearch(sortedArray, 15, 0, sortedArray.Length - 1)));
            #endregion


            #region MergeSort
            MergeSort.print(listToSort);
            MergeSort.mergeSort(listToSort);
            #endregion


            #region QuickSort
            QuickSort.print(listToSort);
            QuickSort.quickSort(listToSort, 0, listToSort.Length - 1);
            QuickSort.print(listToSort);
            #endregion
        }
 protected void OnRemoveElement(DataStructEventArgs <T> e)
 {
     RemoveElement?.Invoke(this, e);
 }
Example #16
0
 public RemoveElementTests()
 {
     _objUnderTest = new RemoveElement();
 }