static void Main(string[] args) { var fourthLargest = QuickSelect.FindKthLargest(new int[] { -10, 2, 1, 9, -6, 44, 0, 3, -17, 8 }, 4); int[][] people = new int[][] { new int[] { 7, 0 }, new int[] { 4, 4 }, new int[] { 7, 1 }, new int[] { 5, 0 }, new int[] { 6, 1 }, new int[] { 5, 2 } }; Array.Sort(people, (a, b) => { if (a[0] > b[0]) { return(1); } else if (a[0] < b[0]) { return(-1); } else { return(0); } }); var sorted = people.OrderByDescending(i => i[0]).ThenBy(i => i[1]).ToArray(); SortedList <int, int> sortedList = new SortedList <int, int>(); HashSet <int> map = new HashSet <int>(); StringBuilder sb = new StringBuilder("Hello"); for (int i = 0; i < sb.Length; i++) { if (sb[i] >= 65 && sb[i] <= 90) { sb[i] = (char)(sb[i] + 32); } } int[] arrayForSort = new int[] { -10, 2, 1, 9, -6, 44, 0, 3, -17, 8 }; BubleSort.Sort(arrayForSort, false); int[] nums2 = new int[] { 0, 1, 2, 4, 5, 6, 7, 9 }; var binRes = binarySearch(nums2, 0, nums2.Length - 1, 0); List <int> list = new List <int>(new int[] { 1, 3, 5, 7, 9 }); var biRes = list.BinarySearch(4); int[] nums = new int[] { 3, 0, 1 }; (new missing_number()).MissingNumber(nums); int seed = 0; var xor = nums.Aggregate(seed++, (x, y) => x ^ y); xor = Enumerable.Range(1, 4).Aggregate((x, y) => x ^ y); (new Swapping_two_integer_variables_without_an_intermediary_variable()).swapArray(nums, 0, 2); ListNode head = new ListNode(0); ListNode pre = head; for (int i = 1; i < 10; i++) { ListNode tmp = new ListNode(i); pre.next = tmp; pre = pre.next; } var bst = (new convert_sorted_list_to_binary_search_treeV2()).SortedListToBST(head); LeetCode.TreeNode node = new LeetCode.TreeNode(1); LeetCode.TreeNode node1 = new LeetCode.TreeNode(2); LeetCode.TreeNode node12 = new LeetCode.TreeNode(5); node.left = node1; node.right = node12; LeetCode.TreeNode node21 = new LeetCode.TreeNode(3); LeetCode.TreeNode node22 = new LeetCode.TreeNode(4); node1.left = node21; node1.right = node22; LeetCode.TreeNode node31 = new LeetCode.TreeNode(6); node12.right = node31; (new flatten_binary_tree_to_linked_list()).Flatten(node); (new construct_binary_tree_from_preorder_and_inorder_traversalV2()).BuildTree( new int[] { 3, 9, 20, 15, 7 }, new int[] { 9, 3, 15, 20, 7 } ); IList <IList <int> > result2 = new List <IList <int> >(); result2.Add(new int[] { 1, 2, 3 }.Concat(new int[] { 4, 5, 6 }).ToArray()); List <int[]> _matrix = new List <int[]>(); _matrix.Add(new int[] { 1, 2, 0, 4 }); _matrix.Add(new int[] { 5, 6, 7, 8 }); _matrix.Add(new int[] { 9, 10, 11, 12 }); var matrix = _matrix.ToArray(); var row1 = matrix[0]; var bol = Enumerable.Any(row1, i => i == 0); for (int i = 0; i < 4; i++) { matrix[0][i] = 0; } //int n = 3; //int[][] matrix = new int[n][]; //for (int i = 0; i < n; i++) //{ // matrix[i] = new int[n]; //} //List<int[]> positions = new List<int[]>(); //int top = 0, left = 0, count = 1; //while (n > 0) //{ // if (n == 1) // { // (positions as List<int[]>).Add(new int[] { top, left }); // break; // } // (positions as List<int[]>).AddRange(Enumerable.Range(left, n - 1).Select(i => new int[] { top, i })); // (positions as List<int[]>).AddRange(Enumerable.Range(top, n - 1).Select(i => new int[] { i, (left + n - 1) })); // (positions as List<int[]>).AddRange(Enumerable.Range(left + 1, n - 1).Reverse().Select(i => new int[] { (top + n - 1), i })); // (positions as List<int[]>).AddRange(Enumerable.Range(top + 1, n - 1).Reverse().Select(i => new int[] { i, left })); // top++; // left++; // n -= 2; //} //Array.ForEach(positions.ToArray(), i => { // matrix[i[0]][i[1]] = count; // count++; // Console.WriteLine($"[{i[0]},{i[1]}] - {matrix[i[0]][i[1]]}"); //}); //int[][] matrix2 = new int[2][]; //IList<int[]> resti = new List<int[]>(); //int width =3, height = 3, top = 1, left = 1; //(resti as List<int[]>).AddRange(Enumerable.Range(left, width - 1).Select(i => new int[] { top, i }).ToArray()); //(resti as List<int[]>).AddRange(Enumerable.Range(top, height - 1).Select(i => new int[] { i, (left + width - 1) }).ToArray()); //(resti as List<int[]>).AddRange(Enumerable.Range(left + 1, width - 1).Reverse().Select(i => new int[] { (top + height - 1), i }).ToArray()); //(resti as List<int[]>).AddRange(Enumerable.Range(top + 1, height - 1).Reverse().Select(i => new int[] { i, left }).ToArray()); //var qwe = resti.Select(i => matrix2[i[0]][i[1]]).ToList(); //ListNode head = new ListNode(1); //ListNode node1 = new ListNode(4); //ListNode node2 = new ListNode(3); //ListNode node3 = new ListNode(2); //ListNode node4 = new ListNode(5); //ListNode node5 = new ListNode(2); //head.next = node1; //node1.next = node2; //node2.next = node3; //node3.next = node4; //node4.next = node5; //var head2 = (new partition_list()).Partition(head, 3); var data1 = (new permutation_sequenceV2()).GetPermutation(4, 10); int[] arr1 = new int[] { 0, 0, 3, 0, 0, 0, 0, 0, 0 }; int[] arr2 = new int[] { -1, 1, 1, 1, 2, 3 }; (new merge_sorted_array()).MergeV2(arr1, 3, arr2, 6); var car = (new CarPlateNumber()).Generate(); int rob = (new house_robber_ii()).Rob(new int[] { 1, 2, 1, 1 }); int[] arr = Enumerable.Repeat(int.MinValue, 4).ToArray(); var perm = (new permutations()).Permute(new int[] { 1, 1, 2 }); var solutions = (new n_queens()).SolveNQueens(4); IList <IList <string> > list2 = new List <IList <string> >(); for (int i = 0; i < 8; i++) { list2.Add(Enumerable.Repeat <string>(".", 8).ToList()); } list2[0][0] = "change"; Dictionary <string, IList <int> > res3 = new Dictionary <string, IList <int> >(); var res4 = res3.Values.ToList(); var res = combination_sum.Answer(new int[] { 2, 3, 4 }, 24); List <char[]> board = new List <char[]>(); board.Add(new char[] { '5', '3', '.', '.', '7', '.', '.', '.', '.' }); board.Add(new char[] { '6', '.', '.', '1', '9', '5', '.', '.', '.' }); board.Add(new char[] { '.', '9', '8', '.', '.', '.', '.', '6', '.' }); board.Add(new char[] { '8', '.', '.', '.', '6', '.', '.', '.', '3' }); board.Add(new char[] { '4', '.', '.', '8', '.', '3', '.', '.', '1' }); board.Add(new char[] { '7', '.', '.', '.', '2', '.', '.', '.', '6' }); board.Add(new char[] { '.', '6', '.', '.', '.', '.', '2', '8', '.' }); board.Add(new char[] { '.', '.', '.', '4', '1', '9', '.', '.', '5' }); board.Add(new char[] { '.', '.', '.', '.', '8', '.', '.', '7', '9' }); var valid = valid_sudoku.Answer(board.ToArray()); var answer = find_first_and_last_position_of_element_in_sorted_array.Answer(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 9); var ans3 = Problem3.Answer(new int[, ] { { 1, 3, 1, 2, 9, 4 }, { 1, 5, 1, 2, 6, 1 }, { 4, 2, 1, 2, 8, 3 }, { 6, 1, 4, 3, 1, 1 } }); var ans32 = Problem3.ImporvedAnswer(new int[, ] { { 1, 3, 1, 2, 9, 4 }, { 1, 5, 1, 2, 6, 1 }, { 4, 2, 1, 2, 8, 3 }, { 6, 1, 4, 3, 1, 1 } }); var ans = Problem2.Answer(4, 6); var ans2 = Problem2.ImporvedAnswer(4, 6); var answer1 = Problem1.Answer1(10); var answer11 = Problem1.ImprovedAnswer1(10); var answer2 = Problem1.Answer2(10); var result = generate_parentheses.GenerateParenthesis(4); foreach (var s in result) { Console.WriteLine(s); } //ThreeSumClosestHelper threeSumClostest = new ThreeSumClosestHelper(); //var result = threeSumClostest.ThreeSumClosest(new int[] { -1, 2, 1, 4 }, 1); //var result = ThreeSum.Answer(new int[] { -1, 0, 1, 2, -1, -4, 3, 4, -5, 6 }); //var result = ThreeSum.Answer(new int[] { 0,0,0,0,0}); //foreach (var s in result) //{ // Console.WriteLine(string.Join(" ", s)); //} //var result = LetterCombinationsOfAPhoneNumber.Answer("789"); //foreach (var s in result) //{ // Console.WriteLine(s); //} //var result = DfsPermutation.Make(new int[] { 1,3,6,2}); //DfsPermutationGenerator dfs = new DfsPermutationGenerator(9); //dfs.Make(); //DfsSolution.subsets(new int[] { 1,2,3}); RomanToInteger.RomanToInt("MCMXCIV"); StringtoInteger.Answer("-91283472332"); LeetCodeTesting(); QuickSortTest(); BinaryHeapTest(); BinarySearchTreeTest(); BinarySearchTreeMirrorTest(); AVLTreeTest(); RedBlackTreeTest(); SplayTreeTest(); SegmentTreeTest_Max(); SegmentTreeTest_Min(); SegmentTreeTest_Sum(); BTreeTest(); Console.ReadLine(); }