Exemplo n.º 1
0
        public static void ProductExceptSelf()
        {
            ArrayOperations arrayOperations = new ArrayOperations();

            int[] result = arrayOperations.ProductExceptSelf(new int[] { 1, 2, 3, 4 });
            PrintArrayOfInts(result);
        }
Exemplo n.º 2
0
        private static void MinSubArrayLen()
        {
            int[]           number   = new int[] { 2, 3, 1, 2, 4, 3 };
            ArrayOperations solution = new ArrayOperations();

            Console.WriteLine(solution.MinSubArrayLen(7, number));
        }
Exemplo n.º 3
0
        public void MoveZeroesToEnds(int[] nums)
        {
            int n = nums.Length;
            int lower = 0, higher = 0, zeros = 0;

            while (lower < n && nums[lower] != 0)
            {
                lower++;
            }

            for (higher = lower + 1; higher < n; higher++)
            {
                if (nums[higher] != 0)
                {
                    int temp = nums[lower];
                    nums[lower++] = nums[higher];
                    nums[higher]  = temp;
                }
            }

            zeros = n - lower;
            int i = (int)Math.Ceiling(zeros / 2.0);

            ArrayOperations arrayOperations = new ArrayOperations();

            arrayOperations.RotateArray(nums, n - i - 1, n - 1);
        }
Exemplo n.º 4
0
        public static void IntersectionOfTwoArrays()
        {
            ArrayOperations arrayOperations = new ArrayOperations();

            int[] result = arrayOperations.Intersect(new int[] { -2147483648, 1, 2, 3 },
                                                     new int[] { 1, -2147483648, -2147483648 });
            PrintArrayOfInts(result);
        }
Exemplo n.º 5
0
        private static void MaxDifference()
        {
            int[] number = new int[] { 4, 2, 4, 0, 0, 0, 3, 5, 1, 50 };
            number = new int[] { -50, 10, 5, 4, 3, 2, 1, 0 };
            ArrayOperations solution = new ArrayOperations();

            Console.WriteLine(solution.MaxDifferenceWithSum(number));
        }
Exemplo n.º 6
0
        private static void ThreeSums()
        {
            int[] number = new int[10] {
                4, 2, 4, 0, 0, 3, 0, 5, 1, 0
            };
            ArrayOperations solution = new ArrayOperations();

            solution.ThreeSum(number);
            PrintArrayOfInts(number);
        }