예제 #1
0
파일: Program.cs 프로젝트: nbukhari/leet
        public static void ProductExceptSelf()
        {
            ArrayOperations arrayOperations = new ArrayOperations();

            int[] result = arrayOperations.ProductExceptSelf(new int[] { 1, 2, 3, 4 });
            PrintArrayOfInts(result);
        }
예제 #2
0
파일: Program.cs 프로젝트: nbukhari/leet
        private static void MinSubArrayLen()
        {
            int[]           number   = new int[] { 2, 3, 1, 2, 4, 3 };
            ArrayOperations solution = new ArrayOperations();

            Console.WriteLine(solution.MinSubArrayLen(7, number));
        }
예제 #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);
        }
예제 #4
0
파일: Program.cs 프로젝트: nbukhari/leet
        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);
        }
예제 #5
0
파일: Program.cs 프로젝트: nbukhari/leet
        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));
        }
예제 #6
0
파일: Program.cs 프로젝트: nbukhari/leet
        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);
        }