static void Main(string[] args)
        {
            #region PairsWithGivenSum

            int[]             arr1  = new int[] { 1, 4, 3, 3, 5, 2, 6 };
            PairsWithGivenSum pairs = new PairsWithGivenSum();
            pairs.FindPairsForGivenSum(arr1, 9);

            #endregion

            #region MajorityElement

            int[]           arr2    = new int[] { 1, 1, 1, 2, 2, 2, 2 };
            MajorityElement element = new MajorityElement();
            element.FindMajorityElement(arr2);
            element.FindMajorityElementUsingMooreAlgo(arr2);

            #endregion

            #region MaxDifference

            int[]         arr3       = new int[] { 3, 1, 4, 7, 5, 100, 10 };
            MaxDifference difference = new MaxDifference();
            difference.FindMaxApproachOne(arr3);
            difference.FindMaxApproachTwo(arr3);

            #endregion

            #region OddOccurrence

            int[]         arr4       = new int[] { 2, 3, 1, 2, 3, 1, 1 };
            OddOccurrence occurrence = new OddOccurrence();
            occurrence.FindOddOccurrence(arr4);
            occurrence.FindOddOccurrenceXOR(arr4);

            #endregion

            Console.ReadKey();
        }
Exemple #2
0
        public void FindMajorityElementTest()
        {
            MajorityElement ME = new MajorityElement();

            ME.FindMajorityElement(new int[] { 4, 4, 3, 5, 4, 4, 6, 7, 4, 4 }).Should().Be(4);
        }
 public void FindMajorityElementTest()
 {
     MajorityElement ME=new MajorityElement();
     ME.FindMajorityElement(new int[] {4, 4, 3, 5, 4, 4, 6, 7,4,4}).Should().Be(4);
 }