static void Main(string[] args) { //int[] nums = { 0, 0, 1, 1, 1, 2, 2, 3, 3, 4 }; //int[] nums = { 1, 2 }; //int[] nums = { 1, 1, 2 }; int[] nums = { 1, 2, 2, 1 }; int[] nums2 = { 2, 2 }; //int[] prices = { 7, 1, 5, 3, 6, 4 }; ArrayProblems array = new ArrayProblems(); array.Intersect(nums, nums2); //Console.WriteLine(sl.RemoveDuplicates(nums).Count()); //Console.WriteLine("--------------"); foreach (var item in nums) { Console.WriteLine(item); } }
static void ArrayExcute() { //var res = ArrayProblems.TwoSum(new int[] { 3,2,4 }, 6); //var res = ArrayProblems.RemoveDuplicates(new int[] { 0,0,1,1,1,2,2,3,3,4 }); //var res = ArrayProblems.RemoveElement(new int[] { 0,1,2,2,3,0,4,2 }, 2); //var res = ArrayProblems.PlusOne(new int[] { 9,9,9,9 }); //foreach (var item in res) { // Console.Write(item.ToString() + " "); //} //ArrayProblems.Merge(new int[] { 1,2,3,0,0,0,0 }, 3, new int[] { 0,2,5,6 }, 4); //var res = ArrayProblems.Generate(5); //for (int i = 0; i < res.Count; i++) { // var row = res[i]; // for (int j = 0; j < row.Count; j++) { // Console.Write(row[j] + " "); // } // Console.WriteLine(""); //} //var res = ArrayProblems.GetRow(3); //foreach (var item in res) { // Console.Write(item.ToString() + " "); //} //var res = ArrayProblems.MaxProfit(new int[] { 7,6,4,3,1 }); //Console.WriteLine("res: " + res); //ArrayProblems.Rotate(new int[] { 1,2,3,4,5,6,7 }, 3); //var res = ArrayProblems.ContainsDuplicate(new int[] { 1,1,2,2,3,4,5,6,7,8,9 }); //var res = ArrayProblems.ContainsNearbyDuplicate(new int[] { 1,0,1,1 }, 1); //var res = ArrayProblems.MissingNumber(new int[] { 9, 6, 4, 2, 3, 5, 7, 0, 1 }); //var res = ArrayProblems.FindMaxConsecutiveOnes(new int[] { 1,1,1,1,1,0,0,1,0,1,1,1,1,1,1 }); //var res = ArrayProblems.MaxDistToClosest(new int[] { 0,0,1,0,1 }); //Console.WriteLine("res: " + res); //var res = ArrayProblems.MatrixReshape(new int[,] { { 1, 2, 3, 5}, { 3, 4, 8, 8 } }, 4, 2); //for (int i = 0; i < res.GetLength(0); i++) { // for (int j = 0; j < res.GetLength(1); j++) { // Console.Write(res[i, j] + " "); // } // Console.WriteLine(""); //} //var res = ArrayProblems.CanPlaceFlowers(new int[] { 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0 }, 4); //var res = ArrayProblems.MaximumProduct(new int[] { -4,-3,-2,1,66 }); //Console.WriteLine("res: " + res); //ArrayProblems.Transpose(new int[][] { new int[] { 1,2,3 }, new int[] { 4,5,6 } }); //var res = ArrayProblems.FindMaxAverage(new int[] { 1,12,-5,-6,50,3 }, 4); //Console.WriteLine("res: " + res); //var res = ArrayProblems.ImageSmoother(new int[,] { // { 1,1,1 }, // { 1,0,1 }, // { 1,1,1 } //}); //for (int i = 0; i < res.GetLength(0); i++) { // for (int j = 0; j < res.GetLength(1); j++) { // Console.Write(res[i, j] + " "); // } // Console.WriteLine(""); //} //var res = ArrayProblems.FindLengthOfLCIS(new int[] { 1,3,4,7,8,8,9,10,12 }); //var res = ArrayProblems.MaxAreaOfIsland(new int[,] { // { 1, 1, 0, 0, 0 }, // { 1, 1, 0, 0, 0 }, // { 0, 0, 0, 1, 1 }, // { 0, 0, 0, 1, 1 } //}); //var res = ArrayProblems.FindShortestSubArray(new int[] { 1,2,2,3,1,4 }); //var res = ArrayProblems.IsOneBitCharacter(new int[] { 1,0 }); //var res = ArrayProblems.PivotIndex(new int[] { -1,-1,-1,0,1,1 }); //var res = ArrayProblems.DominantIndex(new int[] { 0,1,2,4,8,0,0 }); //var res = ArrayProblems.IsToeplitzMatrix(new int[,] { // { 18 }, // { 66 } //}); //Console.WriteLine("res: " + res); //string str1 = "abbxxxxzzy", str2 = "abc", str3 = "abcdddeeeeaabbbcd", str4 = "aaabbbbbaaaaaaacccddddddd"; //var res = ArrayProblems.LargeGroupPositions(str4); //for (int i = 0; i < res.Count; i++) { // for (int j = 0; j < res[i].Count; j++) { // Console.Write(res[i][j] + " "); // } // Console.WriteLine(""); //} //var res = ArrayProblems.FlipAndInvertImage(new int[][] { // new int[] { 1,1,0 }, // new int[] { 1,0,1 }, // new int[] { 0,0,0 } //}); //for (int i = 0; i < res.Length; i++) { // for (int j = 0; j < res[0].Length; j++) { // Console.Write(res[i][j] + " "); // } // Console.WriteLine(""); //} //var res = ArrayProblems.FairCandySwap(new int[] { 2,4 }, new int[] { 1,2,5 }); //for (int i = 0; i < res.Length; i++) { // Console.Write(res[i] + " "); //} //var res = ArrayProblems.MinCostClimbingStairs(new int[] { 1, 100, 1, 1, 1, 100, 1, 1, 100, 1 }); //var res = ArrayProblems.ThirdMax(new int[] { 1, 2, 3, 4, 5, 6 }); // {1,2,-2147483648}, {1,2,2,5,3,5}, {1,2,2}, {1,-2147483648,2}, {5,2,2} //var res = ArrayProblems.CheckPossibility(new int[] { 2,3,3,2,4 }); //var res = ArrayProblems.NumMagicSquaresInside(new int[][] { // new int[] { 4,3,8,4 }, // new int[] { 9,5,1,9 }, // new int[] { 2,7,6,2 } //}); var res = ArrayProblems.FindPairs(new int[] { 1, 1, 2, 2, 3, 3, 4 }, 0); Console.WriteLine("res: " + res); }