diff --git a/LeetcodeProblems/Algorithms/2Sum.js b/LeetcodeProblems/Algorithms/easy/2Sum.js similarity index 100% rename from LeetcodeProblems/Algorithms/2Sum.js rename to LeetcodeProblems/Algorithms/easy/2Sum.js diff --git a/LeetcodeProblems/Algorithms/Award_Budget_Cuts.js b/LeetcodeProblems/Algorithms/easy/Award_Budget_Cuts.js similarity index 100% rename from LeetcodeProblems/Algorithms/Award_Budget_Cuts.js rename to LeetcodeProblems/Algorithms/easy/Award_Budget_Cuts.js diff --git a/LeetcodeProblems/Algorithms/Backspace_String_Compare.js b/LeetcodeProblems/Algorithms/easy/Backspace_String_Compare.js similarity index 100% rename from LeetcodeProblems/Algorithms/Backspace_String_Compare.js rename to LeetcodeProblems/Algorithms/easy/Backspace_String_Compare.js diff --git a/LeetcodeProblems/Algorithms/Binary_Gap.js b/LeetcodeProblems/Algorithms/easy/Binary_Gap.js similarity index 100% rename from LeetcodeProblems/Algorithms/Binary_Gap.js rename to LeetcodeProblems/Algorithms/easy/Binary_Gap.js diff --git a/LeetcodeProblems/Algorithms/Deletion_Distance.js b/LeetcodeProblems/Algorithms/easy/Deletion_Distance.js similarity index 100% rename from LeetcodeProblems/Algorithms/Deletion_Distance.js rename to LeetcodeProblems/Algorithms/easy/Deletion_Distance.js diff --git a/LeetcodeProblems/Algorithms/Flood_Fill.js b/LeetcodeProblems/Algorithms/easy/Flood_Fill.js similarity index 100% rename from LeetcodeProblems/Algorithms/Flood_Fill.js rename to LeetcodeProblems/Algorithms/easy/Flood_Fill.js diff --git a/LeetcodeProblems/Algorithms/Happy_Number.js b/LeetcodeProblems/Algorithms/easy/Happy_Number.js similarity index 100% rename from LeetcodeProblems/Algorithms/Happy_Number.js rename to LeetcodeProblems/Algorithms/easy/Happy_Number.js diff --git a/LeetcodeProblems/Algorithms/Implement_stack_using_queues.js b/LeetcodeProblems/Algorithms/easy/Implement_stack_using_queues.js similarity index 100% rename from LeetcodeProblems/Algorithms/Implement_stack_using_queues.js rename to LeetcodeProblems/Algorithms/easy/Implement_stack_using_queues.js diff --git a/LeetcodeProblems/Algorithms/Longest_Common_Prefix.js b/LeetcodeProblems/Algorithms/easy/Longest_Common_Prefix.js similarity index 100% rename from LeetcodeProblems/Algorithms/Longest_Common_Prefix.js rename to LeetcodeProblems/Algorithms/easy/Longest_Common_Prefix.js diff --git a/LeetcodeProblems/Algorithms/Majority_Element.js b/LeetcodeProblems/Algorithms/easy/Majority_Element.js similarity index 100% rename from LeetcodeProblems/Algorithms/Majority_Element.js rename to LeetcodeProblems/Algorithms/easy/Majority_Element.js diff --git a/LeetcodeProblems/Algorithms/Maximun_Subarray.js b/LeetcodeProblems/Algorithms/easy/Maximun_Subarray.js similarity index 100% rename from LeetcodeProblems/Algorithms/Maximun_Subarray.js rename to LeetcodeProblems/Algorithms/easy/Maximun_Subarray.js diff --git a/LeetcodeProblems/Algorithms/Min_Stack.js b/LeetcodeProblems/Algorithms/easy/Min_Stack.js similarity index 100% rename from LeetcodeProblems/Algorithms/Min_Stack.js rename to LeetcodeProblems/Algorithms/easy/Min_Stack.js diff --git a/LeetcodeProblems/Algorithms/Number_of_Segments_in_a_String.js b/LeetcodeProblems/Algorithms/easy/Number_of_Segments_in_a_String.js similarity index 100% rename from LeetcodeProblems/Algorithms/Number_of_Segments_in_a_String.js rename to LeetcodeProblems/Algorithms/easy/Number_of_Segments_in_a_String.js diff --git a/LeetcodeProblems/Algorithms/Reverse_String_II.js b/LeetcodeProblems/Algorithms/easy/Reverse_String_II.js similarity index 100% rename from LeetcodeProblems/Algorithms/Reverse_String_II.js rename to LeetcodeProblems/Algorithms/easy/Reverse_String_II.js diff --git a/LeetcodeProblems/Algorithms/Same_Tree.js b/LeetcodeProblems/Algorithms/easy/Same_Tree.js similarity index 100% rename from LeetcodeProblems/Algorithms/Same_Tree.js rename to LeetcodeProblems/Algorithms/easy/Same_Tree.js diff --git a/LeetcodeProblems/Algorithms/Shuffle_String.js b/LeetcodeProblems/Algorithms/easy/Shuffle_String.js similarity index 100% rename from LeetcodeProblems/Algorithms/Shuffle_String.js rename to LeetcodeProblems/Algorithms/easy/Shuffle_String.js diff --git a/LeetcodeProblems/Algorithms/Sum_Of_Square_Numbers.js b/LeetcodeProblems/Algorithms/easy/Sum_Of_Square_Numbers.js similarity index 100% rename from LeetcodeProblems/Algorithms/Sum_Of_Square_Numbers.js rename to LeetcodeProblems/Algorithms/easy/Sum_Of_Square_Numbers.js diff --git a/LeetcodeProblems/Algorithms/Symmetric_Tree.js b/LeetcodeProblems/Algorithms/easy/Symmetric_Tree.js similarity index 100% rename from LeetcodeProblems/Algorithms/Symmetric_Tree.js rename to LeetcodeProblems/Algorithms/easy/Symmetric_Tree.js diff --git a/LeetcodeProblems/Algorithms/Tic_Tac_Toe.js b/LeetcodeProblems/Algorithms/easy/Tic_Tac_Toe.js similarity index 100% rename from LeetcodeProblems/Algorithms/Tic_Tac_Toe.js rename to LeetcodeProblems/Algorithms/easy/Tic_Tac_Toe.js diff --git a/LeetcodeProblems/Algorithms/Valid_Parentheses.js b/LeetcodeProblems/Algorithms/easy/Valid_Parentheses.js similarity index 100% rename from LeetcodeProblems/Algorithms/Valid_Parentheses.js rename to LeetcodeProblems/Algorithms/easy/Valid_Parentheses.js diff --git a/LeetcodeProblems/Algorithms/Edit_Distance.js b/LeetcodeProblems/Algorithms/hard/Edit_Distance.js similarity index 100% rename from LeetcodeProblems/Algorithms/Edit_Distance.js rename to LeetcodeProblems/Algorithms/hard/Edit_Distance.js diff --git a/LeetcodeProblems/Algorithms/Longest_Consecutive_Sequence.js b/LeetcodeProblems/Algorithms/hard/Longest_Consecutive_Sequence.js similarity index 100% rename from LeetcodeProblems/Algorithms/Longest_Consecutive_Sequence.js rename to LeetcodeProblems/Algorithms/hard/Longest_Consecutive_Sequence.js diff --git a/LeetcodeProblems/Algorithms/Minimum_Window_Substring.js b/LeetcodeProblems/Algorithms/hard/Minimum_Window_Substring.js similarity index 100% rename from LeetcodeProblems/Algorithms/Minimum_Window_Substring.js rename to LeetcodeProblems/Algorithms/hard/Minimum_Window_Substring.js diff --git a/LeetcodeProblems/Algorithms/NQueens.js b/LeetcodeProblems/Algorithms/hard/NQueens.js similarity index 100% rename from LeetcodeProblems/Algorithms/NQueens.js rename to LeetcodeProblems/Algorithms/hard/NQueens.js diff --git a/LeetcodeProblems/Algorithms/Regular_Expression_Matching.js b/LeetcodeProblems/Algorithms/hard/Regular_Expression_Matching.js similarity index 100% rename from LeetcodeProblems/Algorithms/Regular_Expression_Matching.js rename to LeetcodeProblems/Algorithms/hard/Regular_Expression_Matching.js diff --git a/LeetcodeProblems/Algorithms/Remove_Invalid_Parentheses.js b/LeetcodeProblems/Algorithms/hard/Remove_Invalid_Parentheses.js similarity index 100% rename from LeetcodeProblems/Algorithms/Remove_Invalid_Parentheses.js rename to LeetcodeProblems/Algorithms/hard/Remove_Invalid_Parentheses.js diff --git a/LeetcodeProblems/Algorithms/Set_Matrix_Zeroes.js b/LeetcodeProblems/Algorithms/hard/Set_Matrix_Zeroes.js similarity index 100% rename from LeetcodeProblems/Algorithms/Set_Matrix_Zeroes.js rename to LeetcodeProblems/Algorithms/hard/Set_Matrix_Zeroes.js diff --git a/LeetcodeProblems/Algorithms/merge_k_sorted_lists.js b/LeetcodeProblems/Algorithms/hard/merge_k_sorted_lists.js similarity index 100% rename from LeetcodeProblems/Algorithms/merge_k_sorted_lists.js rename to LeetcodeProblems/Algorithms/hard/merge_k_sorted_lists.js diff --git a/LeetcodeProblems/Algorithms/3Sum.js b/LeetcodeProblems/Algorithms/medium/3Sum.js similarity index 100% rename from LeetcodeProblems/Algorithms/3Sum.js rename to LeetcodeProblems/Algorithms/medium/3Sum.js diff --git a/LeetcodeProblems/Algorithms/3SumClosest.js b/LeetcodeProblems/Algorithms/medium/3SumClosest.js similarity index 100% rename from LeetcodeProblems/Algorithms/3SumClosest.js rename to LeetcodeProblems/Algorithms/medium/3SumClosest.js diff --git a/LeetcodeProblems/Algorithms/Add_Two_Numbers.js b/LeetcodeProblems/Algorithms/medium/Add_Two_Numbers.js similarity index 95% rename from LeetcodeProblems/Algorithms/Add_Two_Numbers.js rename to LeetcodeProblems/Algorithms/medium/Add_Two_Numbers.js index 2169716..3daed64 100644 --- a/LeetcodeProblems/Algorithms/Add_Two_Numbers.js +++ b/LeetcodeProblems/Algorithms/medium/Add_Two_Numbers.js @@ -21,7 +21,7 @@ Explanation: 342 + 465 = 807. * this.next = null; * } */ -var ListNode = require("../../UtilsClasses/ListNode").ListNode; +var ListNode = require("../../../UtilsClasses/ListNode").ListNode; /** * @param {ListNode} l1 diff --git a/LeetcodeProblems/Algorithms/Best_Time_To_Buy_And_Sell_Stock_II.js b/LeetcodeProblems/Algorithms/medium/Best_Time_To_Buy_And_Sell_Stock_II.js similarity index 100% rename from LeetcodeProblems/Algorithms/Best_Time_To_Buy_And_Sell_Stock_II.js rename to LeetcodeProblems/Algorithms/medium/Best_Time_To_Buy_And_Sell_Stock_II.js diff --git a/LeetcodeProblems/Algorithms/Clone_Graph.js b/LeetcodeProblems/Algorithms/medium/Clone_Graph.js similarity index 100% rename from LeetcodeProblems/Algorithms/Clone_Graph.js rename to LeetcodeProblems/Algorithms/medium/Clone_Graph.js diff --git a/LeetcodeProblems/Algorithms/Coin_Change.js b/LeetcodeProblems/Algorithms/medium/Coin_Change.js similarity index 100% rename from LeetcodeProblems/Algorithms/Coin_Change.js rename to LeetcodeProblems/Algorithms/medium/Coin_Change.js diff --git a/LeetcodeProblems/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js b/LeetcodeProblems/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js similarity index 95% rename from LeetcodeProblems/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js rename to LeetcodeProblems/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js index 310624b..021301b 100644 --- a/LeetcodeProblems/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js +++ b/LeetcodeProblems/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js @@ -27,7 +27,7 @@ Return the following binary tree: * this.left = this.right = null; * } */ -var TreeNode = require("../../UtilsClasses/TreeNode").TreeNode; +var TreeNode = require("../../../UtilsClasses/TreeNode").TreeNode; /** * @param {number[]} preorder diff --git a/LeetcodeProblems/Algorithms/Container_With_Most_Water.js b/LeetcodeProblems/Algorithms/medium/Container_With_Most_Water.js similarity index 100% rename from LeetcodeProblems/Algorithms/Container_With_Most_Water.js rename to LeetcodeProblems/Algorithms/medium/Container_With_Most_Water.js diff --git a/LeetcodeProblems/Algorithms/Design_Circular_Deque.js b/LeetcodeProblems/Algorithms/medium/Design_Circular_Deque.js similarity index 100% rename from LeetcodeProblems/Algorithms/Design_Circular_Deque.js rename to LeetcodeProblems/Algorithms/medium/Design_Circular_Deque.js diff --git a/LeetcodeProblems/Algorithms/Escape_The_Ghosts.js b/LeetcodeProblems/Algorithms/medium/Escape_The_Ghosts.js similarity index 100% rename from LeetcodeProblems/Algorithms/Escape_The_Ghosts.js rename to LeetcodeProblems/Algorithms/medium/Escape_The_Ghosts.js diff --git a/LeetcodeProblems/Algorithms/Find_Anagrams.js b/LeetcodeProblems/Algorithms/medium/Find_Anagrams.js similarity index 100% rename from LeetcodeProblems/Algorithms/Find_Anagrams.js rename to LeetcodeProblems/Algorithms/medium/Find_Anagrams.js diff --git a/LeetcodeProblems/Algorithms/Find_Subarrays_With_Equal_Sum.js b/LeetcodeProblems/Algorithms/medium/Find_Subarrays_With_Equal_Sum.js similarity index 100% rename from LeetcodeProblems/Algorithms/Find_Subarrays_With_Equal_Sum.js rename to LeetcodeProblems/Algorithms/medium/Find_Subarrays_With_Equal_Sum.js diff --git a/LeetcodeProblems/Algorithms/Gas_Station.js b/LeetcodeProblems/Algorithms/medium/Gas_Station.js similarity index 100% rename from LeetcodeProblems/Algorithms/Gas_Station.js rename to LeetcodeProblems/Algorithms/medium/Gas_Station.js diff --git a/LeetcodeProblems/Algorithms/Generate_Parenthesis.js b/LeetcodeProblems/Algorithms/medium/Generate_Parenthesis.js similarity index 100% rename from LeetcodeProblems/Algorithms/Generate_Parenthesis.js rename to LeetcodeProblems/Algorithms/medium/Generate_Parenthesis.js diff --git a/LeetcodeProblems/Algorithms/Group_Anagrams.js b/LeetcodeProblems/Algorithms/medium/Group_Anagrams.js similarity index 100% rename from LeetcodeProblems/Algorithms/Group_Anagrams.js rename to LeetcodeProblems/Algorithms/medium/Group_Anagrams.js diff --git a/LeetcodeProblems/Algorithms/K_Closest_Points_to_Origin.js b/LeetcodeProblems/Algorithms/medium/K_Closest_Points_to_Origin.js similarity index 100% rename from LeetcodeProblems/Algorithms/K_Closest_Points_to_Origin.js rename to LeetcodeProblems/Algorithms/medium/K_Closest_Points_to_Origin.js diff --git a/LeetcodeProblems/Algorithms/Kth_Largest_Element_in_an_Array.js b/LeetcodeProblems/Algorithms/medium/Kth_Largest_Element_in_an_Array.js similarity index 100% rename from LeetcodeProblems/Algorithms/Kth_Largest_Element_in_an_Array.js rename to LeetcodeProblems/Algorithms/medium/Kth_Largest_Element_in_an_Array.js diff --git a/LeetcodeProblems/Algorithms/Linked_List_Cycle_II.js b/LeetcodeProblems/Algorithms/medium/Linked_List_Cycle_II.js similarity index 100% rename from LeetcodeProblems/Algorithms/Linked_List_Cycle_II.js rename to LeetcodeProblems/Algorithms/medium/Linked_List_Cycle_II.js diff --git a/LeetcodeProblems/Algorithms/Longest_Palindromic_Substring.js b/LeetcodeProblems/Algorithms/medium/Longest_Palindromic_Substring.js similarity index 100% rename from LeetcodeProblems/Algorithms/Longest_Palindromic_Substring.js rename to LeetcodeProblems/Algorithms/medium/Longest_Palindromic_Substring.js diff --git a/LeetcodeProblems/Algorithms/Longest_Substring.js b/LeetcodeProblems/Algorithms/medium/Longest_Substring.js similarity index 100% rename from LeetcodeProblems/Algorithms/Longest_Substring.js rename to LeetcodeProblems/Algorithms/medium/Longest_Substring.js diff --git a/LeetcodeProblems/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree.js b/LeetcodeProblems/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree.js similarity index 100% rename from LeetcodeProblems/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree.js rename to LeetcodeProblems/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree.js diff --git a/LeetcodeProblems/Algorithms/Max_Area_Of_Island.js b/LeetcodeProblems/Algorithms/medium/Max_Area_Of_Island.js similarity index 100% rename from LeetcodeProblems/Algorithms/Max_Area_Of_Island.js rename to LeetcodeProblems/Algorithms/medium/Max_Area_Of_Island.js diff --git a/LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III.js b/LeetcodeProblems/Algorithms/medium/Max_Consecutive_Ones_III.js similarity index 100% rename from LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III.js rename to LeetcodeProblems/Algorithms/medium/Max_Consecutive_Ones_III.js diff --git a/LeetcodeProblems/Algorithms/Maximal_Square.js b/LeetcodeProblems/Algorithms/medium/Maximal_Square.js similarity index 100% rename from LeetcodeProblems/Algorithms/Maximal_Square.js rename to LeetcodeProblems/Algorithms/medium/Maximal_Square.js diff --git a/LeetcodeProblems/Algorithms/Maximise_Hour_Glass_Sum.js b/LeetcodeProblems/Algorithms/medium/Maximise_Hour_Glass_Sum.js similarity index 100% rename from LeetcodeProblems/Algorithms/Maximise_Hour_Glass_Sum.js rename to LeetcodeProblems/Algorithms/medium/Maximise_Hour_Glass_Sum.js diff --git a/LeetcodeProblems/Algorithms/Minimize_Maximum_Pair_Sum_In_Array.js b/LeetcodeProblems/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array.js similarity index 100% rename from LeetcodeProblems/Algorithms/Minimize_Maximum_Pair_Sum_In_Array.js rename to LeetcodeProblems/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array.js diff --git a/LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid.js b/LeetcodeProblems/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid.js similarity index 100% rename from LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid.js rename to LeetcodeProblems/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid.js diff --git a/LeetcodeProblems/Algorithms/Minimum_Size_Subarray.js b/LeetcodeProblems/Algorithms/medium/Minimum_Size_Subarray.js similarity index 100% rename from LeetcodeProblems/Algorithms/Minimum_Size_Subarray.js rename to LeetcodeProblems/Algorithms/medium/Minimum_Size_Subarray.js diff --git a/LeetcodeProblems/Algorithms/Next_Permutation.js b/LeetcodeProblems/Algorithms/medium/Next_Permutation.js similarity index 100% rename from LeetcodeProblems/Algorithms/Next_Permutation.js rename to LeetcodeProblems/Algorithms/medium/Next_Permutation.js diff --git a/LeetcodeProblems/Algorithms/Number_of_Islands.js b/LeetcodeProblems/Algorithms/medium/Number_of_Islands.js similarity index 100% rename from LeetcodeProblems/Algorithms/Number_of_Islands.js rename to LeetcodeProblems/Algorithms/medium/Number_of_Islands.js diff --git a/LeetcodeProblems/Algorithms/Permutations.js b/LeetcodeProblems/Algorithms/medium/Permutations.js similarity index 100% rename from LeetcodeProblems/Algorithms/Permutations.js rename to LeetcodeProblems/Algorithms/medium/Permutations.js diff --git a/LeetcodeProblems/Algorithms/Permutations_II.js b/LeetcodeProblems/Algorithms/medium/Permutations_II.js similarity index 100% rename from LeetcodeProblems/Algorithms/Permutations_II.js rename to LeetcodeProblems/Algorithms/medium/Permutations_II.js diff --git a/LeetcodeProblems/Algorithms/Permutations_In_String.js b/LeetcodeProblems/Algorithms/medium/Permutations_In_String.js similarity index 100% rename from LeetcodeProblems/Algorithms/Permutations_In_String.js rename to LeetcodeProblems/Algorithms/medium/Permutations_In_String.js diff --git a/LeetcodeProblems/Algorithms/Permutations_With_Duplicates.js b/LeetcodeProblems/Algorithms/medium/Permutations_With_Duplicates.js similarity index 100% rename from LeetcodeProblems/Algorithms/Permutations_With_Duplicates.js rename to LeetcodeProblems/Algorithms/medium/Permutations_With_Duplicates.js diff --git a/LeetcodeProblems/Algorithms/Permutations_Without_Duplicates.js b/LeetcodeProblems/Algorithms/medium/Permutations_Without_Duplicates.js similarity index 100% rename from LeetcodeProblems/Algorithms/Permutations_Without_Duplicates.js rename to LeetcodeProblems/Algorithms/medium/Permutations_Without_Duplicates.js diff --git a/LeetcodeProblems/Algorithms/Restore_IP_Addresses.js b/LeetcodeProblems/Algorithms/medium/Restore_IP_Addresses.js similarity index 100% rename from LeetcodeProblems/Algorithms/Restore_IP_Addresses.js rename to LeetcodeProblems/Algorithms/medium/Restore_IP_Addresses.js diff --git a/LeetcodeProblems/Algorithms/Reverse_Integer.js b/LeetcodeProblems/Algorithms/medium/Reverse_Integer.js similarity index 100% rename from LeetcodeProblems/Algorithms/Reverse_Integer.js rename to LeetcodeProblems/Algorithms/medium/Reverse_Integer.js diff --git a/LeetcodeProblems/Algorithms/SearchIng_Rotated_Sorted_Array.js b/LeetcodeProblems/Algorithms/medium/SearchIng_Rotated_Sorted_Array.js similarity index 100% rename from LeetcodeProblems/Algorithms/SearchIng_Rotated_Sorted_Array.js rename to LeetcodeProblems/Algorithms/medium/SearchIng_Rotated_Sorted_Array.js diff --git a/LeetcodeProblems/Algorithms/Search_a_2D_Matrix.js b/LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix.js similarity index 100% rename from LeetcodeProblems/Algorithms/Search_a_2D_Matrix.js rename to LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix.js diff --git a/LeetcodeProblems/Algorithms/Search_a_2D_Matrix_II.js b/LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix_II.js similarity index 100% rename from LeetcodeProblems/Algorithms/Search_a_2D_Matrix_II.js rename to LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix_II.js diff --git a/LeetcodeProblems/Algorithms/Simplify_Path.js b/LeetcodeProblems/Algorithms/medium/Simplify_Path.js similarity index 100% rename from LeetcodeProblems/Algorithms/Simplify_Path.js rename to LeetcodeProblems/Algorithms/medium/Simplify_Path.js diff --git a/LeetcodeProblems/Algorithms/Spiral_Matrix.js b/LeetcodeProblems/Algorithms/medium/Spiral_Matrix.js similarity index 100% rename from LeetcodeProblems/Algorithms/Spiral_Matrix.js rename to LeetcodeProblems/Algorithms/medium/Spiral_Matrix.js diff --git a/LeetcodeProblems/Algorithms/Subarray_Sum_Equals_K.js b/LeetcodeProblems/Algorithms/medium/Subarray_Sum_Equals_K.js similarity index 100% rename from LeetcodeProblems/Algorithms/Subarray_Sum_Equals_K.js rename to LeetcodeProblems/Algorithms/medium/Subarray_Sum_Equals_K.js diff --git a/LeetcodeProblems/Algorithms/Subsets.js b/LeetcodeProblems/Algorithms/medium/Subsets.js similarity index 100% rename from LeetcodeProblems/Algorithms/Subsets.js rename to LeetcodeProblems/Algorithms/medium/Subsets.js diff --git a/LeetcodeProblems/Algorithms/Swap_Nodes_In_Pairs.js b/LeetcodeProblems/Algorithms/medium/Swap_Nodes_In_Pairs.js similarity index 100% rename from LeetcodeProblems/Algorithms/Swap_Nodes_In_Pairs.js rename to LeetcodeProblems/Algorithms/medium/Swap_Nodes_In_Pairs.js diff --git a/LeetcodeProblems/Algorithms/Time_Needed_Rearrange_Binary_String.js b/LeetcodeProblems/Algorithms/medium/Time_Needed_Rearrange_Binary_String.js similarity index 100% rename from LeetcodeProblems/Algorithms/Time_Needed_Rearrange_Binary_String.js rename to LeetcodeProblems/Algorithms/medium/Time_Needed_Rearrange_Binary_String.js diff --git a/LeetcodeProblems/Algorithms/Top_K_Frequent_Elements.js b/LeetcodeProblems/Algorithms/medium/Top_K_Frequent_Elements.js similarity index 100% rename from LeetcodeProblems/Algorithms/Top_K_Frequent_Elements.js rename to LeetcodeProblems/Algorithms/medium/Top_K_Frequent_Elements.js diff --git a/LeetcodeProblems/Algorithms/Unique_Binary_Search_Trees.js b/LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees.js similarity index 100% rename from LeetcodeProblems/Algorithms/Unique_Binary_Search_Trees.js rename to LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees.js diff --git a/LeetcodeProblems/Algorithms/Unique_Paths.js b/LeetcodeProblems/Algorithms/medium/Unique_Paths.js similarity index 100% rename from LeetcodeProblems/Algorithms/Unique_Paths.js rename to LeetcodeProblems/Algorithms/medium/Unique_Paths.js diff --git a/LeetcodeProblems/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree.js b/LeetcodeProblems/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree.js similarity index 100% rename from LeetcodeProblems/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree.js rename to LeetcodeProblems/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree.js diff --git a/LeetcodeProblems/Databases/Classes_More_Than_5_Students.sql b/LeetcodeProblems/Databases/easy/Classes_More_Than_5_Students.sql similarity index 100% rename from LeetcodeProblems/Databases/Classes_More_Than_5_Students.sql rename to LeetcodeProblems/Databases/easy/Classes_More_Than_5_Students.sql diff --git a/LeetcodeProblems/Databases/Combine_Two_Tables.sql b/LeetcodeProblems/Databases/easy/Combine_Two_Tables.sql similarity index 100% rename from LeetcodeProblems/Databases/Combine_Two_Tables.sql rename to LeetcodeProblems/Databases/easy/Combine_Two_Tables.sql diff --git a/LeetcodeProblems/Databases/Customers_Who_Never_Order.sql b/LeetcodeProblems/Databases/easy/Customers_Who_Never_Order.sql similarity index 100% rename from LeetcodeProblems/Databases/Customers_Who_Never_Order.sql rename to LeetcodeProblems/Databases/easy/Customers_Who_Never_Order.sql diff --git a/LeetcodeProblems/Databases/Delete_Duplicate_Emails.sql b/LeetcodeProblems/Databases/easy/Delete_Duplicate_Emails.sql similarity index 100% rename from LeetcodeProblems/Databases/Delete_Duplicate_Emails.sql rename to LeetcodeProblems/Databases/easy/Delete_Duplicate_Emails.sql diff --git a/LeetcodeProblems/Databases/Duplicate_emails.sql b/LeetcodeProblems/Databases/easy/Duplicate_emails.sql similarity index 100% rename from LeetcodeProblems/Databases/Duplicate_emails.sql rename to LeetcodeProblems/Databases/easy/Duplicate_emails.sql diff --git a/LeetcodeProblems/Databases/Employees_Earning_More_Than_Their_Managers.sql b/LeetcodeProblems/Databases/easy/Employees_Earning_More_Than_Their_Managers.sql similarity index 100% rename from LeetcodeProblems/Databases/Employees_Earning_More_Than_Their_Managers.sql rename to LeetcodeProblems/Databases/easy/Employees_Earning_More_Than_Their_Managers.sql diff --git a/LeetcodeProblems/Databases/Reformat_Department_Table.sql b/LeetcodeProblems/Databases/easy/Reformat_Department_Table.sql similarity index 100% rename from LeetcodeProblems/Databases/Reformat_Department_Table.sql rename to LeetcodeProblems/Databases/easy/Reformat_Department_Table.sql diff --git a/LeetcodeProblems/Databases/Rising_Temperature.sql b/LeetcodeProblems/Databases/easy/Rising_Temperature.sql similarity index 100% rename from LeetcodeProblems/Databases/Rising_Temperature.sql rename to LeetcodeProblems/Databases/easy/Rising_Temperature.sql diff --git a/LeetcodeProblems/Databases/Second_highest_salary.sql b/LeetcodeProblems/Databases/easy/Second_highest_salary.sql similarity index 100% rename from LeetcodeProblems/Databases/Second_highest_salary.sql rename to LeetcodeProblems/Databases/easy/Second_highest_salary.sql diff --git a/LeetcodeProblems/Databases/Human_Traffic_of_Stadium.sql b/LeetcodeProblems/Databases/hard/Human_Traffic_of_Stadium.sql similarity index 100% rename from LeetcodeProblems/Databases/Human_Traffic_of_Stadium.sql rename to LeetcodeProblems/Databases/hard/Human_Traffic_of_Stadium.sql diff --git a/LeetcodeProblems/Databases/Trips_and_Users.sql b/LeetcodeProblems/Databases/hard/Trips_and_Users.sql similarity index 100% rename from LeetcodeProblems/Databases/Trips_and_Users.sql rename to LeetcodeProblems/Databases/hard/Trips_and_Users.sql diff --git a/LeetcodeProblems/Databases/Consecutive_Numbers.sql b/LeetcodeProblems/Databases/medium/Consecutive_Numbers.sql similarity index 100% rename from LeetcodeProblems/Databases/Consecutive_Numbers.sql rename to LeetcodeProblems/Databases/medium/Consecutive_Numbers.sql diff --git a/LeetcodeProblems/Databases/Department_Highest_Salary.sql b/LeetcodeProblems/Databases/medium/Department_Highest_Salary.sql similarity index 100% rename from LeetcodeProblems/Databases/Department_Highest_Salary.sql rename to LeetcodeProblems/Databases/medium/Department_Highest_Salary.sql diff --git a/LeetcodeProblems/Databases/Exchange_Seats.sql b/LeetcodeProblems/Databases/medium/Exchange_Seats.sql similarity index 100% rename from LeetcodeProblems/Databases/Exchange_Seats.sql rename to LeetcodeProblems/Databases/medium/Exchange_Seats.sql diff --git a/LeetcodeProblems/Databases/Rank_Scores.sql b/LeetcodeProblems/Databases/medium/Rank_Scores.sql similarity index 100% rename from LeetcodeProblems/Databases/Rank_Scores.sql rename to LeetcodeProblems/Databases/medium/Rank_Scores.sql diff --git a/LeetcodeProblems/Databases/nth_Highest_Salary.sql b/LeetcodeProblems/Databases/medium/nth_Highest_Salary.sql similarity index 100% rename from LeetcodeProblems/Databases/nth_Highest_Salary.sql rename to LeetcodeProblems/Databases/medium/nth_Highest_Salary.sql diff --git a/LeetcodeProblemsTests/Algorithms/2Sum_Test.js b/LeetcodeProblemsTests/Algorithms/easy/2Sum_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/2Sum_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/2Sum_Test.js index 19f8ce0..2fd2dbc 100644 --- a/LeetcodeProblemsTests/Algorithms/2Sum_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/2Sum_Test.js @@ -1,7 +1,6 @@ const assert = require("assert"); -const twoSum = require("../../LeetcodeProblems/Algorithms/2Sum").twoSum; -const twoSum2 = require("../../LeetcodeProblems/Algorithms/2Sum").twoSum2; - +const twoSum = require("../../../LeetcodeProblems/Algorithms/easy/2Sum").twoSum; +const twoSum2 = require("../../../LeetcodeProblems/Algorithms/easy/2Sum").twoSum2; var testFirstSolution = function () { assert.deepEqual([0,1], twoSum([2,7,11,15], 9)); diff --git a/LeetcodeProblemsTests/Algorithms/Award_Budget_Cuts_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Award_Budget_Cuts_Test.js similarity index 71% rename from LeetcodeProblemsTests/Algorithms/Award_Budget_Cuts_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Award_Budget_Cuts_Test.js index 2dacf4a..797fb52 100644 --- a/LeetcodeProblemsTests/Algorithms/Award_Budget_Cuts_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Award_Budget_Cuts_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const cutAwardBadges = require("../../LeetcodeProblems/Algorithms/Award_Budget_Cuts").cutAwardBadges; +const cutAwardBadges = require("../../../LeetcodeProblems/Algorithms/easy/Award_Budget_Cuts").cutAwardBadges; function test() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/Backspace_String_Compare_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Backspace_String_Compare_Test.js similarity index 71% rename from LeetcodeProblemsTests/Algorithms/Backspace_String_Compare_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Backspace_String_Compare_Test.js index 22fbc39..4b73dfe 100644 --- a/LeetcodeProblemsTests/Algorithms/Backspace_String_Compare_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Backspace_String_Compare_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); -const backspaceCompare = require("../../LeetcodeProblems/Algorithms/Backspace_String_Compare").backspaceCompare; -const backspaceCompare2 = require("../../LeetcodeProblems/Algorithms/Backspace_String_Compare").backspaceCompare2; +const backspaceCompare = require("../../../LeetcodeProblems/Algorithms/easy/Backspace_String_Compare").backspaceCompare; +const backspaceCompare2 = require("../../../LeetcodeProblems/Algorithms/easy/Backspace_String_Compare").backspaceCompare2; function test() { assert.equal(backspaceCompare("ab#c", "ad#c"), true); // true diff --git a/LeetcodeProblemsTests/Algorithms/Binary_Gap_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Binary_Gap_Test.js similarity index 64% rename from LeetcodeProblemsTests/Algorithms/Binary_Gap_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Binary_Gap_Test.js index 6025822..c89a4a6 100644 --- a/LeetcodeProblemsTests/Algorithms/Binary_Gap_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Binary_Gap_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const binaryGap = require("../../LeetcodeProblems/Algorithms/Binary_Gap").binaryGap; +const binaryGap = require("../../../LeetcodeProblems/Algorithms/easy/Binary_Gap").binaryGap; function test() { assert.equal(binaryGap(22), 2); // 10110 diff --git a/LeetcodeProblemsTests/Algorithms/Deletion_Distance_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Deletion_Distance_Test.js similarity index 67% rename from LeetcodeProblemsTests/Algorithms/Deletion_Distance_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Deletion_Distance_Test.js index d1ae378..7ac3d80 100644 --- a/LeetcodeProblemsTests/Algorithms/Deletion_Distance_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Deletion_Distance_Test.js @@ -1,7 +1,7 @@ const assert = require("assert"); -var deletionDistance = require("../../LeetcodeProblems/Algorithms/Deletion_Distance").deletionDistance; -var deletionDistance2 = require("../../LeetcodeProblems/Algorithms/Deletion_Distance").deletionDistance2; -var deletionDistanceDP = require("../../LeetcodeProblems/Algorithms/Deletion_Distance").deletionDistanceDP; +var deletionDistance = require("../../../LeetcodeProblems/Algorithms/easy/Deletion_Distance").deletionDistance; +var deletionDistance2 = require("../../../LeetcodeProblems/Algorithms/easy/Deletion_Distance").deletionDistance2; +var deletionDistanceDP = require("../../../LeetcodeProblems/Algorithms/easy/Deletion_Distance").deletionDistanceDP; function test() { assert.equal(deletionDistance("dog", "frog"), 3); diff --git a/LeetcodeProblemsTests/Algorithms/Flood_Fill_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Flood_Fill_Test.js similarity index 68% rename from LeetcodeProblemsTests/Algorithms/Flood_Fill_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Flood_Fill_Test.js index 447795f..557af9f 100644 --- a/LeetcodeProblemsTests/Algorithms/Flood_Fill_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Flood_Fill_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const floodFill = require("../../LeetcodeProblems/Algorithms/Flood_Fill").floodFill; +const floodFill = require("../../../LeetcodeProblems/Algorithms/easy/Flood_Fill").floodFill; function test() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/Happy_Number_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Happy_Number_Test.js similarity index 63% rename from LeetcodeProblemsTests/Algorithms/Happy_Number_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Happy_Number_Test.js index fa4544d..00e198a 100644 --- a/LeetcodeProblemsTests/Algorithms/Happy_Number_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Happy_Number_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const isHappy = require("../../LeetcodeProblems/Algorithms/Happy_Number").isHappy; +const isHappy = require("../../../LeetcodeProblems/Algorithms/easy/Happy_Number").isHappy; var test = function () { assert.equal(isHappy(19),true); diff --git a/LeetcodeProblemsTests/Algorithms/Implement_stack_using_queues_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Implement_stack_using_queues_Test.js similarity index 79% rename from LeetcodeProblemsTests/Algorithms/Implement_stack_using_queues_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Implement_stack_using_queues_Test.js index 8e3fb3a..a5d1735 100644 --- a/LeetcodeProblemsTests/Algorithms/Implement_stack_using_queues_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Implement_stack_using_queues_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const MyStack = require("../../LeetcodeProblems/Algorithms/Implement_stack_using_queues").MyStack; +const MyStack = require("../../../LeetcodeProblems/Algorithms/easy/Implement_stack_using_queues").MyStack; var test = function () { var myStack = new MyStack(); diff --git a/LeetcodeProblemsTests/Algorithms/Longest_Common_Prefix_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Longest_Common_Prefix_Test.js similarity index 68% rename from LeetcodeProblemsTests/Algorithms/Longest_Common_Prefix_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Longest_Common_Prefix_Test.js index 92c6c7a..7a7109a 100644 --- a/LeetcodeProblemsTests/Algorithms/Longest_Common_Prefix_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Longest_Common_Prefix_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); -const longestCommonPrefix = require("../../LeetcodeProblems/Algorithms/Longest_Common_Prefix").longestCommonPrefix; +const longestCommonPrefix = require("../../../LeetcodeProblems/Algorithms/easy/Longest_Common_Prefix").longestCommonPrefix; function test() { assert.equal(longestCommonPrefix(["flower","flow","flight"]), "fl"); diff --git a/LeetcodeProblemsTests/Algorithms/Majority_Element_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Majority_Element_Test.js similarity index 68% rename from LeetcodeProblemsTests/Algorithms/Majority_Element_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Majority_Element_Test.js index b9420d2..96c08b8 100644 --- a/LeetcodeProblemsTests/Algorithms/Majority_Element_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Majority_Element_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const majorityElement = require("../../LeetcodeProblems/Algorithms/Majority_Element").majorityElement; +const majorityElement = require("../../../LeetcodeProblems/Algorithms/easy/Majority_Element").majorityElement; function test() { assert.equal(majorityElement([2,2,3]), 2); diff --git a/LeetcodeProblemsTests/Algorithms/Maximun_Subarray_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Maximun_Subarray_Test.js similarity index 70% rename from LeetcodeProblemsTests/Algorithms/Maximun_Subarray_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Maximun_Subarray_Test.js index 68fd57e..d408555 100644 --- a/LeetcodeProblemsTests/Algorithms/Maximun_Subarray_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Maximun_Subarray_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const maxSubArray = require("../../LeetcodeProblems/Algorithms/Maximun_Subarray").maxSubArray; +const maxSubArray = require("../../../LeetcodeProblems/Algorithms/easy/Maximun_Subarray").maxSubArray; function test() { assert.equal(maxSubArray([]), 0); diff --git a/LeetcodeProblemsTests/Algorithms/Min_Stack_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Min_Stack_Test.js similarity index 78% rename from LeetcodeProblemsTests/Algorithms/Min_Stack_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Min_Stack_Test.js index 5cbddda..d94fb53 100644 --- a/LeetcodeProblemsTests/Algorithms/Min_Stack_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Min_Stack_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const MinStack = require("../../LeetcodeProblems/Algorithms/Min_Stack").MinStack; +const MinStack = require("../../../LeetcodeProblems/Algorithms/easy/Min_Stack").MinStack; function test() { var minStack = new MinStack(); diff --git a/LeetcodeProblemsTests/Algorithms/Number_of_Segments_in_a_String_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Number_of_Segments_in_a_String_Test.js similarity index 74% rename from LeetcodeProblemsTests/Algorithms/Number_of_Segments_in_a_String_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Number_of_Segments_in_a_String_Test.js index 13a982f..a33787f 100644 --- a/LeetcodeProblemsTests/Algorithms/Number_of_Segments_in_a_String_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Number_of_Segments_in_a_String_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const countSegments = require("../../LeetcodeProblems/Algorithms/Number_of_Segments_in_a_String").countSegments; +const countSegments = require("../../../LeetcodeProblems/Algorithms/easy/Number_of_Segments_in_a_String").countSegments; function test() { assert.equal(countSegments(" "), 0); diff --git a/LeetcodeProblemsTests/Algorithms/Reverse_String_II_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Reverse_String_II_Test.js similarity index 74% rename from LeetcodeProblemsTests/Algorithms/Reverse_String_II_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Reverse_String_II_Test.js index 9fae9d4..897f97f 100644 --- a/LeetcodeProblemsTests/Algorithms/Reverse_String_II_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Reverse_String_II_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const reverseStr = require("../../LeetcodeProblems/Algorithms/Reverse_String_II").reverseStr; +const reverseStr = require("../../../LeetcodeProblems/Algorithms/easy/Reverse_String_II").reverseStr; var test = function() { assert.equal(reverseStr("abcdefg", 2), "bacdfeg"); diff --git a/LeetcodeProblemsTests/Algorithms/Same_Tree_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Same_Tree_Test.js similarity index 100% rename from LeetcodeProblemsTests/Algorithms/Same_Tree_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Same_Tree_Test.js diff --git a/LeetcodeProblemsTests/Algorithms/Shuffle_String_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Shuffle_String_Test.js similarity index 74% rename from LeetcodeProblemsTests/Algorithms/Shuffle_String_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Shuffle_String_Test.js index cb37d91..8ca038b 100644 --- a/LeetcodeProblemsTests/Algorithms/Shuffle_String_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Shuffle_String_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const restoreString = require("../../LeetcodeProblems/Algorithms/Shuffle_String").restoreString; +const restoreString = require("../../../LeetcodeProblems/Algorithms/easy/Shuffle_String").restoreString; var test = function () { assert.equal(restoreString("codeleet",[4,5,6,7,0,2,1,3]),"leetcode"); diff --git a/LeetcodeProblemsTests/Algorithms/Sum_Of_Square_Numbers_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Sum_Of_Square_Numbers_Test.js similarity index 76% rename from LeetcodeProblemsTests/Algorithms/Sum_Of_Square_Numbers_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Sum_Of_Square_Numbers_Test.js index 26c033a..1a93b94 100644 --- a/LeetcodeProblemsTests/Algorithms/Sum_Of_Square_Numbers_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Sum_Of_Square_Numbers_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const judgeSquareSum = require("../../LeetcodeProblems/Algorithms/Sum_Of_Square_Numbers").judgeSquareSum; +const judgeSquareSum = require("../../../LeetcodeProblems/Algorithms/easy/Sum_Of_Square_Numbers").judgeSquareSum; var test = function() { assert.strictEqual(judgeSquareSum(0), true); diff --git a/LeetcodeProblemsTests/Algorithms/Symmetric_Tree_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Symmetric_Tree_Test.js similarity index 100% rename from LeetcodeProblemsTests/Algorithms/Symmetric_Tree_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Symmetric_Tree_Test.js diff --git a/LeetcodeProblemsTests/Algorithms/Tic_Tac_Toe_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Tic_Tac_Toe_Test.js similarity index 81% rename from LeetcodeProblemsTests/Algorithms/Tic_Tac_Toe_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Tic_Tac_Toe_Test.js index d1d98ec..a9ae9e3 100644 --- a/LeetcodeProblemsTests/Algorithms/Tic_Tac_Toe_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Tic_Tac_Toe_Test.js @@ -1,4 +1,4 @@ -const TicTacToe = require("../../LeetcodeProblems/Algorithms/Tic_Tac_Toe").TicTacToe; +const TicTacToe = require("../../../LeetcodeProblems/Algorithms/easy/Tic_Tac_Toe").TicTacToe; var test = function() { let ticTacToe = new TicTacToe(); diff --git a/LeetcodeProblemsTests/Algorithms/Valid_Parentheses_Test.js b/LeetcodeProblemsTests/Algorithms/easy/Valid_Parentheses_Test.js similarity index 77% rename from LeetcodeProblemsTests/Algorithms/Valid_Parentheses_Test.js rename to LeetcodeProblemsTests/Algorithms/easy/Valid_Parentheses_Test.js index a110c7b..499a6ba 100644 --- a/LeetcodeProblemsTests/Algorithms/Valid_Parentheses_Test.js +++ b/LeetcodeProblemsTests/Algorithms/easy/Valid_Parentheses_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const isValid = require("../../LeetcodeProblems/Algorithms/Valid_Parentheses").isValid; +const isValid = require("../../../LeetcodeProblems/Algorithms/easy/Valid_Parentheses").isValid; var test = function () { assert.strictEqual(isValid(""), true); diff --git a/LeetcodeProblemsTests/Algorithms/Edit_Distance_Test.js b/LeetcodeProblemsTests/Algorithms/hard/Edit_Distance_Test.js similarity index 60% rename from LeetcodeProblemsTests/Algorithms/Edit_Distance_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/Edit_Distance_Test.js index 2810420..46732ca 100644 --- a/LeetcodeProblemsTests/Algorithms/Edit_Distance_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/Edit_Distance_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); -var minDistance = require("../../LeetcodeProblems/Algorithms/Edit_Distance").minDistance; -var minDistance2 = require("../../LeetcodeProblems/Algorithms/Edit_Distance").minDistance2; +var minDistance = require("../../../LeetcodeProblems/Algorithms/hard/Edit_Distance").minDistance; +var minDistance2 = require("../../../LeetcodeProblems/Algorithms/hard/Edit_Distance").minDistance2; function test() { assert.equal(minDistance("ros", "horse"), 3); diff --git a/LeetcodeProblemsTests/Algorithms/Longest_Consecutive_Sequence_Test.js b/LeetcodeProblemsTests/Algorithms/hard/Longest_Consecutive_Sequence_Test.js similarity index 74% rename from LeetcodeProblemsTests/Algorithms/Longest_Consecutive_Sequence_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/Longest_Consecutive_Sequence_Test.js index 00cc6ed..96c2bf8 100644 --- a/LeetcodeProblemsTests/Algorithms/Longest_Consecutive_Sequence_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/Longest_Consecutive_Sequence_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const longestConsecutive = require("../../LeetcodeProblems/Algorithms/Longest_Consecutive_Sequence").longestConsecutive; +const longestConsecutive = require("../../../LeetcodeProblems/Algorithms/hard/Longest_Consecutive_Sequence").longestConsecutive; function test() { assert.equal(longestConsecutive([100, 1, 200, 3, 2, 400, 201]), 3); diff --git a/LeetcodeProblemsTests/Algorithms/Minimum_Window_Substring_Test.js b/LeetcodeProblemsTests/Algorithms/hard/Minimum_Window_Substring_Test.js similarity index 77% rename from LeetcodeProblemsTests/Algorithms/Minimum_Window_Substring_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/Minimum_Window_Substring_Test.js index e580710..452aacf 100644 --- a/LeetcodeProblemsTests/Algorithms/Minimum_Window_Substring_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/Minimum_Window_Substring_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const minWindow = require("../../LeetcodeProblems/Algorithms/Minimum_Window_Substring").minWindow; +const minWindow = require("../../../LeetcodeProblems/Algorithms/hard/Minimum_Window_Substring").minWindow; function test() { assert.equal(minWindow("ADOBECODEBANC", "ABC"), "BANC"); diff --git a/LeetcodeProblemsTests/Algorithms/NQueens_Test.js b/LeetcodeProblemsTests/Algorithms/hard/NQueens_Test.js similarity index 86% rename from LeetcodeProblemsTests/Algorithms/NQueens_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/NQueens_Test.js index 42d95ff..18ed528 100644 --- a/LeetcodeProblemsTests/Algorithms/NQueens_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/NQueens_Test.js @@ -1,5 +1,5 @@ // const assert = require("assert"); -const solveNQueens = require("../../LeetcodeProblems/Algorithms/NQueens").solveNQueens; +const solveNQueens = require("../../../LeetcodeProblems/Algorithms/hard/NQueens").solveNQueens; // TODO: Add assertions diff --git a/LeetcodeProblemsTests/Algorithms/Regular_Expression_Matching_Test.js b/LeetcodeProblemsTests/Algorithms/hard/Regular_Expression_Matching_Test.js similarity index 77% rename from LeetcodeProblemsTests/Algorithms/Regular_Expression_Matching_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/Regular_Expression_Matching_Test.js index 95bca74..c8ee882 100644 --- a/LeetcodeProblemsTests/Algorithms/Regular_Expression_Matching_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/Regular_Expression_Matching_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const isMatch = require("../../LeetcodeProblems/Algorithms/Regular_Expression_Matching").isMatch; +const isMatch = require("../../../LeetcodeProblems/Algorithms/hard/Regular_Expression_Matching").isMatch; var test = function() { assert.equal(isMatch("aa", "a"), false); diff --git a/LeetcodeProblemsTests/Algorithms/Remove_Invalid_Parentheses_Test.js b/LeetcodeProblemsTests/Algorithms/hard/Remove_Invalid_Parentheses_Test.js similarity index 69% rename from LeetcodeProblemsTests/Algorithms/Remove_Invalid_Parentheses_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/Remove_Invalid_Parentheses_Test.js index d345205..6b8f995 100644 --- a/LeetcodeProblemsTests/Algorithms/Remove_Invalid_Parentheses_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/Remove_Invalid_Parentheses_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const removeInvalidParentheses = require("../../LeetcodeProblems/Algorithms/Remove_Invalid_Parentheses").removeInvalidParentheses; +const removeInvalidParentheses = require("../../../LeetcodeProblems/Algorithms/hard/Remove_Invalid_Parentheses").removeInvalidParentheses; var test = function() { assert.equal(removeInvalidParentheses("))))(()"), "()"); diff --git a/LeetcodeProblemsTests/Algorithms/Set_Matrix_Zeroes_Test.js b/LeetcodeProblemsTests/Algorithms/hard/Set_Matrix_Zeroes_Test.js similarity index 66% rename from LeetcodeProblemsTests/Algorithms/Set_Matrix_Zeroes_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/Set_Matrix_Zeroes_Test.js index 98709fe..39b9e87 100644 --- a/LeetcodeProblemsTests/Algorithms/Set_Matrix_Zeroes_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/Set_Matrix_Zeroes_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const setZeroes = require("../../LeetcodeProblems/Algorithms/Set_Matrix_Zeroes").setZeroes; +const setZeroes = require("../../../LeetcodeProblems/Algorithms/hard/Set_Matrix_Zeroes").setZeroes; var test = function() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/merge_k_sorted_lists_Test.js b/LeetcodeProblemsTests/Algorithms/hard/merge_k_sorted_lists_Test.js similarity index 68% rename from LeetcodeProblemsTests/Algorithms/merge_k_sorted_lists_Test.js rename to LeetcodeProblemsTests/Algorithms/hard/merge_k_sorted_lists_Test.js index 0db1c51..ba1051e 100644 --- a/LeetcodeProblemsTests/Algorithms/merge_k_sorted_lists_Test.js +++ b/LeetcodeProblemsTests/Algorithms/hard/merge_k_sorted_lists_Test.js @@ -1,7 +1,7 @@ const assert = require("assert"); -const ListNodeTestHelper = require("../../UtilsClasses/ListNodeTestHelper"); -var ListNode = require("../../UtilsClasses/ListNode").ListNode; -const mergeKLists = require("../../LeetcodeProblems/Algorithms/merge_k_sorted_lists").mergeKLists; +const ListNodeTestHelper = require("../../../UtilsClasses/ListNodeTestHelper"); +var ListNode = require("../../../UtilsClasses/ListNode").ListNode; +const mergeKLists = require("../../../LeetcodeProblems/Algorithms/hard/merge_k_sorted_lists").mergeKLists; function test() { assert.deepEqual(mergeKLists([]), null); diff --git a/LeetcodeProblemsTests/Algorithms/3Sum_Closest_Test.js b/LeetcodeProblemsTests/Algorithms/medium/3Sum_Closest_Test.js similarity index 71% rename from LeetcodeProblemsTests/Algorithms/3Sum_Closest_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/3Sum_Closest_Test.js index 5d397ad..a0f109c 100644 --- a/LeetcodeProblemsTests/Algorithms/3Sum_Closest_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/3Sum_Closest_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); const threeSumClosest = - require("../../LeetcodeProblems/Algorithms/3SumClosest").threeSumClosest; + require("../../../LeetcodeProblems/Algorithms/medium/3SumClosest").threeSumClosest; var test = function () { assert.equal(2, threeSumClosest([-1, 2, 1, -4], 1)); diff --git a/LeetcodeProblemsTests/Algorithms/3Sum_Test.js b/LeetcodeProblemsTests/Algorithms/medium/3Sum_Test.js similarity index 84% rename from LeetcodeProblemsTests/Algorithms/3Sum_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/3Sum_Test.js index 4dd352c..445c40b 100644 --- a/LeetcodeProblemsTests/Algorithms/3Sum_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/3Sum_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const threeSum = require("../../LeetcodeProblems/Algorithms/3Sum").threeSum; +const threeSum = require("../../../LeetcodeProblems/Algorithms/medium/3Sum").threeSum; var test = function () { assert.deepEqual(threeSum([]), []); diff --git a/LeetcodeProblemsTests/Algorithms/Add_Two_Numbers_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Add_Two_Numbers_Test.js similarity index 69% rename from LeetcodeProblemsTests/Algorithms/Add_Two_Numbers_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Add_Two_Numbers_Test.js index 5af6f69..9675a65 100644 --- a/LeetcodeProblemsTests/Algorithms/Add_Two_Numbers_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Add_Two_Numbers_Test.js @@ -1,6 +1,6 @@ -const addTwoNumbers = require("../../LeetcodeProblems/Algorithms/Add_Two_Numbers").addTwoNumbers; -const ListNodeTestHelper = require("../../UtilsClasses/ListNodeTestHelper"); -var ListNode = require("../../UtilsClasses/ListNode").ListNode; +const addTwoNumbers = require("../../../LeetcodeProblems/Algorithms/medium/Add_Two_Numbers").addTwoNumbers; +const ListNodeTestHelper = require("../../../UtilsClasses/ListNodeTestHelper"); +var ListNode = require("../../../UtilsClasses/ListNode").ListNode; function test() { const list1 = ListNode.linkenList([1,2,3,4]); diff --git a/LeetcodeProblemsTests/Algorithms/Best_Time_To_Buy_And_Sell_Stock_II_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Best_Time_To_Buy_And_Sell_Stock_II_Test.js similarity index 60% rename from LeetcodeProblemsTests/Algorithms/Best_Time_To_Buy_And_Sell_Stock_II_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Best_Time_To_Buy_And_Sell_Stock_II_Test.js index c3207fb..7a2561c 100644 --- a/LeetcodeProblemsTests/Algorithms/Best_Time_To_Buy_And_Sell_Stock_II_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Best_Time_To_Buy_And_Sell_Stock_II_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const maxProfit = require("../../LeetcodeProblems/Algorithms/Best_Time_To_Buy_And_Sell_Stock_II").maxProfit; +const maxProfit = require("../../../LeetcodeProblems/Algorithms/medium/Best_Time_To_Buy_And_Sell_Stock_II").maxProfit; function test() { assert.equal(maxProfit([7,1,5,3,6,4]), 7); diff --git a/LeetcodeProblemsTests/Algorithms/Clone_Graph_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Clone_Graph_Test.js similarity index 100% rename from LeetcodeProblemsTests/Algorithms/Clone_Graph_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Clone_Graph_Test.js diff --git a/LeetcodeProblemsTests/Algorithms/Coin_Change_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Coin_Change_Test.js similarity index 78% rename from LeetcodeProblemsTests/Algorithms/Coin_Change_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Coin_Change_Test.js index df5ae45..9bd9a50 100644 --- a/LeetcodeProblemsTests/Algorithms/Coin_Change_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Coin_Change_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const coinChange = require("../../LeetcodeProblems/Algorithms/Coin_Change").coinChange; +const coinChange = require("../../../LeetcodeProblems/Algorithms/medium/Coin_Change").coinChange; function test() { assert.equal(coinChange([], 3), -1); diff --git a/LeetcodeProblemsTests/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal_Test.js similarity index 52% rename from LeetcodeProblemsTests/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal_Test.js index 1ddea51..793d6fd 100644 --- a/LeetcodeProblemsTests/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal_Test.js @@ -1,5 +1,5 @@ // const assert = require("assert"); -var buildTree = require("../../LeetcodeProblems/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal").buildTree; +var buildTree = require("../../../LeetcodeProblems/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal").buildTree; function test() { // TODO diff --git a/LeetcodeProblemsTests/Algorithms/Container_With_Most_Water_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Container_With_Most_Water_Test.js similarity index 61% rename from LeetcodeProblemsTests/Algorithms/Container_With_Most_Water_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Container_With_Most_Water_Test.js index cb08735..7d52f78 100644 --- a/LeetcodeProblemsTests/Algorithms/Container_With_Most_Water_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Container_With_Most_Water_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const maxArea = require("../../LeetcodeProblems/Algorithms/Container_With_Most_Water").maxArea; +const maxArea = require("../../../LeetcodeProblems/Algorithms/medium/Container_With_Most_Water").maxArea; function test() { assert.equal(49, maxArea([1,8,6,2,5,4,8,3,7])); diff --git a/LeetcodeProblemsTests/Algorithms/Design_Circular_Deque_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Design_Circular_Deque_Test.js similarity index 80% rename from LeetcodeProblemsTests/Algorithms/Design_Circular_Deque_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Design_Circular_Deque_Test.js index cf8bc81..5a3ddd2 100644 --- a/LeetcodeProblemsTests/Algorithms/Design_Circular_Deque_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Design_Circular_Deque_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -var MyCircularDeque = require("../../LeetcodeProblems/Algorithms/Design_Circular_Deque").MyCircularDeque; +var MyCircularDeque = require("../../../LeetcodeProblems/Algorithms/medium/Design_Circular_Deque").MyCircularDeque; var test = function() { const obj = new MyCircularDeque(3); diff --git a/LeetcodeProblemsTests/Algorithms/Escape_The_Ghosts_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Escape_The_Ghosts_Test.js similarity index 70% rename from LeetcodeProblemsTests/Algorithms/Escape_The_Ghosts_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Escape_The_Ghosts_Test.js index 4225fbf..8ce944c 100644 --- a/LeetcodeProblemsTests/Algorithms/Escape_The_Ghosts_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Escape_The_Ghosts_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); -var escapeGhosts = require("../../LeetcodeProblems/Algorithms/Escape_The_Ghosts").escapeGhosts; +var escapeGhosts = require("../../../LeetcodeProblems/Algorithms/medium/Escape_The_Ghosts").escapeGhosts; function test() { assert.equal(escapeGhosts([[1, 0], [0, 3]], [0, 1]), true); diff --git a/LeetcodeProblemsTests/Algorithms/Find_Anagrams_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Find_Anagrams_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Find_Anagrams_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Find_Anagrams_Test.js index 3b90a57..13de13a 100644 --- a/LeetcodeProblemsTests/Algorithms/Find_Anagrams_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Find_Anagrams_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); -var findAnagrams = require("../../LeetcodeProblems/Algorithms/Find_Anagrams").findAnagrams; +var findAnagrams = require("../../../LeetcodeProblems/Algorithms/medium/Find_Anagrams").findAnagrams; function test() { assert.deepEqual([], findAnagrams("AA", "BB")); diff --git a/LeetcodeProblemsTests/Algorithms/Find_Subarrays_With_Equal_Sum_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Find_Subarrays_With_Equal_Sum_Test.js similarity index 65% rename from LeetcodeProblemsTests/Algorithms/Find_Subarrays_With_Equal_Sum_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Find_Subarrays_With_Equal_Sum_Test.js index 956a327..8a6ad5f 100644 --- a/LeetcodeProblemsTests/Algorithms/Find_Subarrays_With_Equal_Sum_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Find_Subarrays_With_Equal_Sum_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const findSubarrays = require("../../LeetcodeProblems/Algorithms/Find_Subarrays_With_Equal_Sum").findSubarrays; +const findSubarrays = require("../../../LeetcodeProblems/Algorithms/medium/Find_Subarrays_With_Equal_Sum").findSubarrays; var test = function () { assert.equal(findSubarrays([4,2,4]), true); diff --git a/LeetcodeProblemsTests/Algorithms/Gas_Station_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Gas_Station_Test.js similarity index 70% rename from LeetcodeProblemsTests/Algorithms/Gas_Station_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Gas_Station_Test.js index ef35fe6..ebee7ad 100644 --- a/LeetcodeProblemsTests/Algorithms/Gas_Station_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Gas_Station_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const canCompleteCircuit = require("../../LeetcodeProblems/Algorithms/Gas_Station").canCompleteCircuit; +const canCompleteCircuit = require("../../../LeetcodeProblems/Algorithms/medium/Gas_Station").canCompleteCircuit; function test() { assert.equal(3, canCompleteCircuit([1,2,3,4,5], [3,4,5,1,2])); diff --git a/LeetcodeProblemsTests/Algorithms/Generate_Parenthesis_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Generate_Parenthesis_Test.js similarity index 100% rename from LeetcodeProblemsTests/Algorithms/Generate_Parenthesis_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Generate_Parenthesis_Test.js diff --git a/LeetcodeProblemsTests/Algorithms/Group_Anagrams_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Group_Anagrams_Test.js similarity index 68% rename from LeetcodeProblemsTests/Algorithms/Group_Anagrams_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Group_Anagrams_Test.js index c871e7e..1588606 100644 --- a/LeetcodeProblemsTests/Algorithms/Group_Anagrams_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Group_Anagrams_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const groupAnagrams = require("../../LeetcodeProblems/Algorithms/Group_Anagrams").groupAnagrams; +const groupAnagrams = require("../../../LeetcodeProblems/Algorithms/medium/Group_Anagrams").groupAnagrams; function test() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/K_Closest_Points_to_Origin_Test.js b/LeetcodeProblemsTests/Algorithms/medium/K_Closest_Points_to_Origin_Test.js similarity index 54% rename from LeetcodeProblemsTests/Algorithms/K_Closest_Points_to_Origin_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/K_Closest_Points_to_Origin_Test.js index 3164742..24a6f0e 100644 --- a/LeetcodeProblemsTests/Algorithms/K_Closest_Points_to_Origin_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/K_Closest_Points_to_Origin_Test.js @@ -1,16 +1,17 @@ const assert = require("assert"); -var kClosest = require("../../LeetcodeProblems/Algorithms/K_Closest_Points_to_Origin").kClosest; +var kClosest = require("../../../LeetcodeProblems/Algorithms/medium/K_Closest_Points_to_Origin").kClosest; function test1() { var points = [[1,3],[-2,2]]; var output = [[-2,2]]; - assert.strictEqual(kClosest(points,1), output); + assert.deepStrictEqual(kClosest(points,1), output); } function test2() { var points = [[3,3],[5,-1],[-2,4]]; var output = [[-2,4],[3,3]]; - assert.strictEqual(kClosest(points,2), output); + + assert.deepStrictEqual(kClosest(points,2).sort, output.sort); } function test() { diff --git a/LeetcodeProblemsTests/Algorithms/Kth_Largest_Element_in_an_Array_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Kth_Largest_Element_in_an_Array_Test.js similarity index 69% rename from LeetcodeProblemsTests/Algorithms/Kth_Largest_Element_in_an_Array_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Kth_Largest_Element_in_an_Array_Test.js index 156d2e1..94ff0a5 100644 --- a/LeetcodeProblemsTests/Algorithms/Kth_Largest_Element_in_an_Array_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Kth_Largest_Element_in_an_Array_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const findKthLargest = require("../../LeetcodeProblems/Algorithms/Kth_Largest_Element_in_an_Array").findKthLargest; +const findKthLargest = require("../../../LeetcodeProblems/Algorithms/medium/Kth_Largest_Element_in_an_Array").findKthLargest; function test() { assert.equal(findKthLargest([3,2,1,5,6,4], 2), 5); diff --git a/LeetcodeProblemsTests/Algorithms/Linked_List_Cycle_II_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Linked_List_Cycle_II_Test.js similarity index 77% rename from LeetcodeProblemsTests/Algorithms/Linked_List_Cycle_II_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Linked_List_Cycle_II_Test.js index 5014106..665843d 100644 --- a/LeetcodeProblemsTests/Algorithms/Linked_List_Cycle_II_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Linked_List_Cycle_II_Test.js @@ -1,6 +1,6 @@ const assert = require("assert"); -var ListNode = require("../../UtilsClasses/ListNode").ListNode; -const detectCycle = require("../../LeetcodeProblems/Algorithms/Linked_List_Cycle_II").detectCycle; +var ListNode = require("../../../UtilsClasses/ListNode").ListNode; +const detectCycle = require("../../../LeetcodeProblems/Algorithms/medium/Linked_List_Cycle_II").detectCycle; var test = function() { const cycle = buildCycle(); diff --git a/LeetcodeProblemsTests/Algorithms/Longest_Palindromic_Substring_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Longest_Palindromic_Substring_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Longest_Palindromic_Substring_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Longest_Palindromic_Substring_Test.js index cab1b1b..863a459 100644 --- a/LeetcodeProblemsTests/Algorithms/Longest_Palindromic_Substring_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Longest_Palindromic_Substring_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const longestPalindrome = require("../../LeetcodeProblems/Algorithms/Longest_Palindromic_Substring").longestPalindrome; +const longestPalindrome = require("../../../LeetcodeProblems/Algorithms/medium/Longest_Palindromic_Substring").longestPalindrome; function test() { assert.equal(longestPalindrome("pabcdcbte"), "bcdcb"); diff --git a/LeetcodeProblemsTests/Algorithms/Longest_Substring_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Longest_Substring_Test.js similarity index 72% rename from LeetcodeProblemsTests/Algorithms/Longest_Substring_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Longest_Substring_Test.js index f4a873e..1595415 100644 --- a/LeetcodeProblemsTests/Algorithms/Longest_Substring_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Longest_Substring_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const lengthOfLongestSubstring = require("../../LeetcodeProblems/Algorithms/Longest_Substring").lengthOfLongestSubstring; +const lengthOfLongestSubstring = require("../../../LeetcodeProblems/Algorithms/medium/Longest_Substring").lengthOfLongestSubstring; function test() { assert.equal(4, lengthOfLongestSubstring("abcdbcd")); diff --git a/LeetcodeProblemsTests/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree_Test.js similarity index 71% rename from LeetcodeProblemsTests/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree_Test.js index 045f9ba..af6d8ff 100644 --- a/LeetcodeProblemsTests/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree_Test.js @@ -1,7 +1,7 @@ // const assert = require("assert"); -var TreeNode = require("../../UtilsClasses/TreeNode").TreeNode; -const lowestCommonAncestor = require("../../LeetcodeProblems/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree").lowestCommonAncestor; -const lowestCommonAncestor2 = require("../../LeetcodeProblems/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree").lowestCommonAncestor2; +var TreeNode = require("../../../UtilsClasses/TreeNode").TreeNode; +const lowestCommonAncestor = require("../../../LeetcodeProblems/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree").lowestCommonAncestor; +const lowestCommonAncestor2 = require("../../../LeetcodeProblems/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree").lowestCommonAncestor2; var test = function() { var root = new TreeNode(3); diff --git a/LeetcodeProblemsTests/Algorithms/Max_Area_Of_Island_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Max_Area_Of_Island_Test.js similarity index 89% rename from LeetcodeProblemsTests/Algorithms/Max_Area_Of_Island_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Max_Area_Of_Island_Test.js index b8269e6..28e8f34 100644 --- a/LeetcodeProblemsTests/Algorithms/Max_Area_Of_Island_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Max_Area_Of_Island_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const { maxAreaOfIsland } = require("../../LeetcodeProblems/Algorithms/Max_Area_Of_Island"); +const { maxAreaOfIsland } = require("../../../LeetcodeProblems/Algorithms/medium/Max_Area_Of_Island"); function test1() { var matrix = [ diff --git a/LeetcodeProblemsTests/Algorithms/Max_Consecutive_Ones_III_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Max_Consecutive_Ones_III_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Max_Consecutive_Ones_III_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Max_Consecutive_Ones_III_Test.js index ef4eb81..3314c85 100644 --- a/LeetcodeProblemsTests/Algorithms/Max_Consecutive_Ones_III_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Max_Consecutive_Ones_III_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const longestOnes = require("../../LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III").longestOnes; +const longestOnes = require("../../../LeetcodeProblems/Algorithms/medium/Max_Consecutive_Ones_III").longestOnes; function test() { assert.equal(1, longestOnes([1], 1)); diff --git a/LeetcodeProblemsTests/Algorithms/Maximal_Square_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Maximal_Square_Test.js similarity index 76% rename from LeetcodeProblemsTests/Algorithms/Maximal_Square_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Maximal_Square_Test.js index 11a0764..b29b21b 100644 --- a/LeetcodeProblemsTests/Algorithms/Maximal_Square_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Maximal_Square_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const maximalSquare = require("../../LeetcodeProblems/Algorithms/Maximal_Square").maximalSquare; +const maximalSquare = require("../../../LeetcodeProblems/Algorithms/medium/Maximal_Square").maximalSquare; function test() { assert.equal(maximalSquare([["1","0"]]), 1); diff --git a/LeetcodeProblemsTests/Algorithms/Maximise_Hour_Glass_Sum.js b/LeetcodeProblemsTests/Algorithms/medium/Maximise_Hour_Glass_Sum.js similarity index 67% rename from LeetcodeProblemsTests/Algorithms/Maximise_Hour_Glass_Sum.js rename to LeetcodeProblemsTests/Algorithms/medium/Maximise_Hour_Glass_Sum.js index f728cfd..f3f2cf2 100644 --- a/LeetcodeProblemsTests/Algorithms/Maximise_Hour_Glass_Sum.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Maximise_Hour_Glass_Sum.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const maxSum = require("../../LeetcodeProblems/Algorithms/Maximise_Hour_Glass_Sum").maxSum; +const maxSum = require("../../../LeetcodeProblems/Algorithms/medium/Maximise_Hour_Glass_Sum").maxSum; function test() { assert.equal(maxSum([[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]), 30); diff --git a/LeetcodeProblemsTests/Algorithms/Minimize_Maximum_Pair_Sum_In_Array_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array_Test.js similarity index 64% rename from LeetcodeProblemsTests/Algorithms/Minimize_Maximum_Pair_Sum_In_Array_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array_Test.js index 3180536..1842614 100644 --- a/LeetcodeProblemsTests/Algorithms/Minimize_Maximum_Pair_Sum_In_Array_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const minPairSum = require("../../LeetcodeProblems/Algorithms/Minimize_Maximum_Pair_Sum_In_Array").minPairSum; +const minPairSum = require("../../../LeetcodeProblems/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array").minPairSum; var test = function () { assert.equal(minPairSum([3,5,2,3]), 7); diff --git a/LeetcodeProblemsTests/Algorithms/Minimum_Add_To_Make_Parentheses_Valid_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid_Test.js similarity index 73% rename from LeetcodeProblemsTests/Algorithms/Minimum_Add_To_Make_Parentheses_Valid_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid_Test.js index 69baf4d..9c75aa4 100644 --- a/LeetcodeProblemsTests/Algorithms/Minimum_Add_To_Make_Parentheses_Valid_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const minAddToMakeValid = require("../../LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid").minAddToMakeValid; +const minAddToMakeValid = require("../../../LeetcodeProblems/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid").minAddToMakeValid; var test = function() { assert.strictEqual(1, minAddToMakeValid("()(")); diff --git a/LeetcodeProblemsTests/Algorithms/Minimum_Size_Subarray_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Minimum_Size_Subarray_Test.js similarity index 80% rename from LeetcodeProblemsTests/Algorithms/Minimum_Size_Subarray_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Minimum_Size_Subarray_Test.js index a09502e..c5f8628 100644 --- a/LeetcodeProblemsTests/Algorithms/Minimum_Size_Subarray_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Minimum_Size_Subarray_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const minSubArrayLength = require("../../LeetcodeProblems/Algorithms/Minimum_Size_Subarray").minSubArrayLength; +const minSubArrayLength = require("../../../LeetcodeProblems/Algorithms/medium/Minimum_Size_Subarray").minSubArrayLength; function test() { assert.equal(0, minSubArrayLength(10, [])); diff --git a/LeetcodeProblemsTests/Algorithms/Next_Permutation_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Next_Permutation_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Next_Permutation_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Next_Permutation_Test.js index ec47f8c..f892f38 100644 --- a/LeetcodeProblemsTests/Algorithms/Next_Permutation_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Next_Permutation_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const nextPermutation = require("../../LeetcodeProblems/Algorithms/Next_Permutation").nextPermutation; +const nextPermutation = require("../../../LeetcodeProblems/Algorithms/medium/Next_Permutation").nextPermutation; function test() { let test1 = [1,2,3]; diff --git a/LeetcodeProblemsTests/Algorithms/Number_of_Islands_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Number_of_Islands_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Number_of_Islands_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Number_of_Islands_Test.js index 1a46197..f3ef5e6 100644 --- a/LeetcodeProblemsTests/Algorithms/Number_of_Islands_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Number_of_Islands_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const numIslands = require("../../LeetcodeProblems/Algorithms/Number_of_Islands").numIslands; +const numIslands = require("../../../LeetcodeProblems/Algorithms/medium/Number_of_Islands").numIslands; function test() { assert.equal(numIslands([[1]]), 1); diff --git a/LeetcodeProblemsTests/Algorithms/Permutations_II_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Permutations_II_Test.js similarity index 87% rename from LeetcodeProblemsTests/Algorithms/Permutations_II_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Permutations_II_Test.js index e464f80..20d1702 100644 --- a/LeetcodeProblemsTests/Algorithms/Permutations_II_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Permutations_II_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const permuteUnique = require("../../LeetcodeProblems/Algorithms/Permutations_II").permuteUnique; +const permuteUnique = require("../../../LeetcodeProblems/Algorithms/medium/Permutations_II").permuteUnique; function test() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/Permutations_In_String_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Permutations_In_String_Test.js similarity index 72% rename from LeetcodeProblemsTests/Algorithms/Permutations_In_String_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Permutations_In_String_Test.js index f8d4536..975bda8 100644 --- a/LeetcodeProblemsTests/Algorithms/Permutations_In_String_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Permutations_In_String_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const checkInclusion = require("../../LeetcodeProblems/Algorithms/Permutations_In_String").checkInclusion; +const checkInclusion = require("../../../LeetcodeProblems/Algorithms/medium/Permutations_In_String").checkInclusion; function test() { assert.equal(false, checkInclusion("abc", "ab")); diff --git a/LeetcodeProblemsTests/Algorithms/Permutations_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Permutations_Test.js similarity index 78% rename from LeetcodeProblemsTests/Algorithms/Permutations_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Permutations_Test.js index f3f338e..1473732 100644 --- a/LeetcodeProblemsTests/Algorithms/Permutations_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Permutations_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const permute = require("../../LeetcodeProblems/Algorithms/Permutations").permute; +const permute = require("../../../LeetcodeProblems/Algorithms/medium/Permutations").permute; function test() { assert.deepEqual(permute([]), [ [] ]); diff --git a/LeetcodeProblemsTests/Algorithms/Permutations_With_Duplicates_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Permutations_With_Duplicates_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Permutations_With_Duplicates_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Permutations_With_Duplicates_Test.js index 984192b..e355512 100644 --- a/LeetcodeProblemsTests/Algorithms/Permutations_With_Duplicates_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Permutations_With_Duplicates_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const subsetWithoutDuplicates = require("../../LeetcodeProblems/Algorithms/Permutations_With_Duplicates").subsetWithoutDuplicates; +const subsetWithoutDuplicates = require("../../../LeetcodeProblems/Algorithms/medium/Permutations_With_Duplicates").subsetWithoutDuplicates; var test = function() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/Permutations_Without_Duplicates_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Permutations_Without_Duplicates_Test.js similarity index 65% rename from LeetcodeProblemsTests/Algorithms/Permutations_Without_Duplicates_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Permutations_Without_Duplicates_Test.js index 379b627..a22e4e7 100644 --- a/LeetcodeProblemsTests/Algorithms/Permutations_Without_Duplicates_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Permutations_Without_Duplicates_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const subsetWithoutDuplicates = require("../../LeetcodeProblems/Algorithms/Permutations_Without_Duplicates").subsetWithoutDuplicates; +const subsetWithoutDuplicates = require("../../../LeetcodeProblems/Algorithms/medium/Permutations_Without_Duplicates").subsetWithoutDuplicates; var test = function() { assert.deepEqual( diff --git a/LeetcodeProblemsTests/Algorithms/Restore_IP_Addresses_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Restore_IP_Addresses_Test.js similarity index 68% rename from LeetcodeProblemsTests/Algorithms/Restore_IP_Addresses_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Restore_IP_Addresses_Test.js index 9cf9ceb..17e2521 100644 --- a/LeetcodeProblemsTests/Algorithms/Restore_IP_Addresses_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Restore_IP_Addresses_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const restoreIpAddresses = require("../../LeetcodeProblems/Algorithms/Restore_IP_Addresses").restoreIpAddresses; +const restoreIpAddresses = require("../../../LeetcodeProblems/Algorithms/medium/Restore_IP_Addresses").restoreIpAddresses; var test = function() { assert.deepEqual(restoreIpAddresses("010010"), [ "0.10.0.10", "0.100.1.0"]); diff --git a/LeetcodeProblemsTests/Algorithms/Reverse_Integer_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Reverse_Integer_Test.js similarity index 66% rename from LeetcodeProblemsTests/Algorithms/Reverse_Integer_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Reverse_Integer_Test.js index 95da676..627d72a 100644 --- a/LeetcodeProblemsTests/Algorithms/Reverse_Integer_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Reverse_Integer_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const reverseInteger = require("../../LeetcodeProblems/Algorithms/Reverse_Integer").reverseInteger; +const reverseInteger = require("../../../LeetcodeProblems/Algorithms/medium/Reverse_Integer").reverseInteger; var test = function() { assert.equal(reverseInteger(123), 321); diff --git a/LeetcodeProblemsTests/Algorithms/SearchIng_Rotated_Sorted_Array_Test.js b/LeetcodeProblemsTests/Algorithms/medium/SearchIng_Rotated_Sorted_Array_Test.js similarity index 55% rename from LeetcodeProblemsTests/Algorithms/SearchIng_Rotated_Sorted_Array_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/SearchIng_Rotated_Sorted_Array_Test.js index 866496c..47bf614 100644 --- a/LeetcodeProblemsTests/Algorithms/SearchIng_Rotated_Sorted_Array_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/SearchIng_Rotated_Sorted_Array_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const search = require("../../LeetcodeProblems/Algorithms/SearchIng_Rotated_Sorted_Array").search; +const search = require("../../../LeetcodeProblems/Algorithms/medium/SearchIng_Rotated_Sorted_Array").search; var test = function() { assert.equal(search([4,5,6,7,0,1,2], 5), 1); diff --git a/LeetcodeProblemsTests/Algorithms/Search_a_2D_Matrix_II_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Search_a_2D_Matrix_II_Test.js similarity index 76% rename from LeetcodeProblemsTests/Algorithms/Search_a_2D_Matrix_II_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Search_a_2D_Matrix_II_Test.js index 933f5dd..5dff4a5 100644 --- a/LeetcodeProblemsTests/Algorithms/Search_a_2D_Matrix_II_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Search_a_2D_Matrix_II_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const searchMatrix = require("../../LeetcodeProblems/Algorithms/Search_a_2D_Matrix_II").searchMatrix; +const searchMatrix = require("../../../LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix_II").searchMatrix; const matrix1 = [ [1,4,7, 11,15], diff --git a/LeetcodeProblemsTests/Algorithms/Search_a_2D_Matrix_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Search_a_2D_Matrix_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Search_a_2D_Matrix_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Search_a_2D_Matrix_Test.js index f5e7380..f07b9c0 100644 --- a/LeetcodeProblemsTests/Algorithms/Search_a_2D_Matrix_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Search_a_2D_Matrix_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const searchMatrix = require("../../LeetcodeProblems/Algorithms/Search_a_2D_Matrix").searchMatrix; +const searchMatrix = require("../../../LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix").searchMatrix; var test = function() { assert.equal(searchMatrix([], 0), false); diff --git a/LeetcodeProblemsTests/Algorithms/Simplify_Path_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Simplify_Path_Test.js similarity index 81% rename from LeetcodeProblemsTests/Algorithms/Simplify_Path_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Simplify_Path_Test.js index 8815e3d..0b0c1ce 100644 --- a/LeetcodeProblemsTests/Algorithms/Simplify_Path_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Simplify_Path_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const simplifyPath = require("../../LeetcodeProblems/Algorithms/Simplify_Path").simplifyPath; +const simplifyPath = require("../../../LeetcodeProblems/Algorithms/medium/Simplify_Path").simplifyPath; var test = function() { assert.equal(simplifyPath("/../c"), "/c"); diff --git a/LeetcodeProblemsTests/Algorithms/Spiral_Matrix_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Spiral_Matrix_Test.js similarity index 70% rename from LeetcodeProblemsTests/Algorithms/Spiral_Matrix_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Spiral_Matrix_Test.js index ff56856..8002ee5 100644 --- a/LeetcodeProblemsTests/Algorithms/Spiral_Matrix_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Spiral_Matrix_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const spiralOrder = require("../../LeetcodeProblems/Algorithms/Spiral_Matrix").spiralOrder; +const spiralOrder = require("../../../LeetcodeProblems/Algorithms/medium/Spiral_Matrix").spiralOrder; var test = function() { const matrix = [ diff --git a/LeetcodeProblemsTests/Algorithms/Subarray_Sum_Equals_K_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Subarray_Sum_Equals_K_Test.js similarity index 72% rename from LeetcodeProblemsTests/Algorithms/Subarray_Sum_Equals_K_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Subarray_Sum_Equals_K_Test.js index 1b3481b..8c85c57 100644 --- a/LeetcodeProblemsTests/Algorithms/Subarray_Sum_Equals_K_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Subarray_Sum_Equals_K_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const subarraySum = require("../../LeetcodeProblems/Algorithms/Subarray_Sum_Equals_K").subarraySum; +const subarraySum = require("../../../LeetcodeProblems/Algorithms/medium/Subarray_Sum_Equals_K").subarraySum; var test = function() { assert.strictEqual(subarraySum([1,1,1], 2), 2); diff --git a/LeetcodeProblemsTests/Algorithms/Subsets_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Subsets_Test.js similarity index 79% rename from LeetcodeProblemsTests/Algorithms/Subsets_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Subsets_Test.js index c175b83..de1a1b1 100644 --- a/LeetcodeProblemsTests/Algorithms/Subsets_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Subsets_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const subsets = require("../../LeetcodeProblems/Algorithms/Subsets").subsets; +const subsets = require("../../../LeetcodeProblems/Algorithms/medium/Subsets").subsets; function test() { assert.deepEqual(subsets([]), [[]]); diff --git a/LeetcodeProblemsTests/Algorithms/Swap_Nodes_In_Pairs_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Swap_Nodes_In_Pairs_Test.js similarity index 61% rename from LeetcodeProblemsTests/Algorithms/Swap_Nodes_In_Pairs_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Swap_Nodes_In_Pairs_Test.js index 06df05e..5a34ed4 100644 --- a/LeetcodeProblemsTests/Algorithms/Swap_Nodes_In_Pairs_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Swap_Nodes_In_Pairs_Test.js @@ -1,7 +1,7 @@ // const assert = require("assert"); -const ListNode = require("../../UtilsClasses/ListNode").ListNode; -const ListNodeTestHelper = require("../../UtilsClasses/ListNodeTestHelper"); -const swapPairs = require("../../LeetcodeProblems/Algorithms/Swap_Nodes_In_Pairs").swapPairs; +const ListNode = require("../../../UtilsClasses/ListNode").ListNode; +const ListNodeTestHelper = require("../../../UtilsClasses/ListNodeTestHelper"); +const swapPairs = require("../../../LeetcodeProblems/Algorithms/medium/Swap_Nodes_In_Pairs").swapPairs; var test = function () { ListNodeTestHelper.assertList(swapPairs(ListNode.linkenList([1,2,3,4])), [2,1,4,3]); diff --git a/LeetcodeProblemsTests/Algorithms/Time_Needed_Rearrange_Binary_String_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Time_Needed_Rearrange_Binary_String_Test.js similarity index 56% rename from LeetcodeProblemsTests/Algorithms/Time_Needed_Rearrange_Binary_String_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Time_Needed_Rearrange_Binary_String_Test.js index a51e1bf..ba01f9c 100644 --- a/LeetcodeProblemsTests/Algorithms/Time_Needed_Rearrange_Binary_String_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Time_Needed_Rearrange_Binary_String_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const secondsToRemoveOccurrences = require("../../LeetcodeProblems/Algorithms/Time_Needed_Rearrange_Binary_String").secondsToRemoveOccurrences; +const secondsToRemoveOccurrences = require("../../../LeetcodeProblems/Algorithms/medium/Time_Needed_Rearrange_Binary_String").secondsToRemoveOccurrences; function test() { assert.equal(secondsToRemoveOccurrences("0110101"), 4); diff --git a/LeetcodeProblemsTests/Algorithms/Top_K_Frequent_Elements_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Top_K_Frequent_Elements_Test.js similarity index 71% rename from LeetcodeProblemsTests/Algorithms/Top_K_Frequent_Elements_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Top_K_Frequent_Elements_Test.js index 5fc89a1..6ccb077 100644 --- a/LeetcodeProblemsTests/Algorithms/Top_K_Frequent_Elements_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Top_K_Frequent_Elements_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const topKFrequent = require("../../LeetcodeProblems/Algorithms/Top_K_Frequent_Elements").topKFrequent; +const topKFrequent = require("../../../LeetcodeProblems/Algorithms/medium/Top_K_Frequent_Elements").topKFrequent; var test = function () { assert.deepEqual(topKFrequent([1,1,1,2,2,3], 2).sort(), [1,2]); diff --git a/LeetcodeProblemsTests/Algorithms/Unique_Binary_Search_Trees_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Unique_Binary_Search_Trees_Test.js similarity index 62% rename from LeetcodeProblemsTests/Algorithms/Unique_Binary_Search_Trees_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Unique_Binary_Search_Trees_Test.js index 5a10c4a..96f28e2 100644 --- a/LeetcodeProblemsTests/Algorithms/Unique_Binary_Search_Trees_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Unique_Binary_Search_Trees_Test.js @@ -1,7 +1,7 @@ const assert = require("assert"); -const numTrees1 = require("../../LeetcodeProblems/Algorithms/Unique_Binary_Search_Trees").numTrees1; -const numTrees2 = require("../../LeetcodeProblems/Algorithms/Unique_Binary_Search_Trees").numTrees2; -const numTrees3 = require("../../LeetcodeProblems/Algorithms/Unique_Binary_Search_Trees").numTrees3; +const numTrees1 = require("../../../LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees").numTrees1; +const numTrees2 = require("../../../LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees").numTrees2; +const numTrees3 = require("../../../LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees").numTrees3; var test = function () { assert.strictEqual(numTrees1(1), 1); diff --git a/LeetcodeProblemsTests/Algorithms/Unique_Paths_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Unique_Paths_Test.js similarity index 54% rename from LeetcodeProblemsTests/Algorithms/Unique_Paths_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Unique_Paths_Test.js index a67592a..9330218 100644 --- a/LeetcodeProblemsTests/Algorithms/Unique_Paths_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Unique_Paths_Test.js @@ -1,7 +1,7 @@ const assert = require("assert"); -const uniquePaths1 = require("../../LeetcodeProblems/Algorithms/Unique_Paths").uniquePaths1; -const uniquePaths2 = require("../../LeetcodeProblems/Algorithms/Unique_Paths").uniquePaths2; -const uniquePaths3 = require("../../LeetcodeProblems/Algorithms/Unique_Paths").uniquePaths3; +const uniquePaths1 = require("../../../LeetcodeProblems/Algorithms/medium/Unique_Paths").uniquePaths1; +const uniquePaths2 = require("../../../LeetcodeProblems/Algorithms/medium/Unique_Paths").uniquePaths2; +const uniquePaths3 = require("../../../LeetcodeProblems/Algorithms/medium/Unique_Paths").uniquePaths3; var test = function() { assert.strictEqual(uniquePaths1(10,4), 220); diff --git a/LeetcodeProblemsTests/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree_Test.js b/LeetcodeProblemsTests/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree_Test.js similarity index 75% rename from LeetcodeProblemsTests/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree_Test.js rename to LeetcodeProblemsTests/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree_Test.js index ad60f96..9bab778 100644 --- a/LeetcodeProblemsTests/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree_Test.js +++ b/LeetcodeProblemsTests/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree_Test.js @@ -1,5 +1,5 @@ const assert = require("assert"); -const isValidSerialization = require("../../LeetcodeProblems/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree").isValidSerialization; +const isValidSerialization = require("../../../LeetcodeProblems/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree").isValidSerialization; var test = function() { assert.strictEqual(isValidSerialization(""), true); diff --git a/README.md b/README.md index 0b2e13d..cc94197 100644 --- a/README.md +++ b/README.md @@ -15,84 +15,85 @@ The solutions are located under `/LeetcodeProblems`. Each problem has a test fil | Name | Level | Link | | - | - | - | -| [Edit Distance ](/LeetcodeProblems/Algorithms/Edit_Distance.js) | Hard | https://leetcode.com/problems/edit-distance/ | -| [Remove Invalid Parentheses ](/LeetcodeProblems/Algorithms/Remove_Invalid_Parentheses.js) | Hard | https://leetcode.com/problems/remove-invalid-parentheses/ | -| [Longest Consecutive Sequence ](/LeetcodeProblems/Algorithms/Longest_Consecutive_Sequence.js) | Hard | https://leetcode.com/problems/longest-consecutive-sequence/ | -| [Minimum Window Substring ](/LeetcodeProblems/Algorithms/Minimum_Window_Substring.js) | Hard | https://leetcode.com/problems/minimum-window-substring/ | -| [Regular Expression Matching ](/LeetcodeProblems/Algorithms/Regular_Expression_Matching.js) | Hard | https://leetcode.com/problems/regular-expression-matching/ | -| [NQueens ](/LeetcodeProblems/Algorithms/NQueens.js) | Hard | https://leetcode.com/problems/n-queens/ | -| [merge k sorted lists ](/LeetcodeProblems/Algorithms/merge_k_sorted_lists.js) | Hard | https://leetcode.com/problems/merge-k-sorted-lists/ | -| [Set Matrix Zeroes](/LeetcodeProblems/Algorithms/Set_Matrix_Zeroes.js) | Hard | https://leetcode.com/problems/set-matrix-zeroes/ | -| [Subarray Sum Equals K ](/LeetcodeProblems/Algorithms/Subarray_Sum_Equals_K.js) | Medium | https://leetcode.com/problems/subarray-sum-equals-k/ | -| [3Sum Closest](/LeetcodeProblems/Algorithms/3SumClosest.js) | Medium | https://leetcode.com/problems/3sum-closest/ | -| [3Sum ](/LeetcodeProblems/Algorithms/3Sum.js) | Medium | https://leetcode.com/problems/3sum/ | -| [NumberOfIslands ](/LeetcodeProblems/Algorithms/Number_of_Islands.js) | Medium | https://leetcode.com/problems/number-of-islands/ | -| [Swap Nodes in Pairs](/LeetcodeProblems/Algorithms/Swap_Nodes_in_Pairs.js) | Medium | https://leetcode.com/problems/swap-nodes-in-pairs/ | -| [Add Two Numbers ](/LeetcodeProblems/Algorithms/Add_Two_Numbers.js) | Medium | https://leetcode.com/problems/add-two-numbers/ | -| [Clone Graph ](/LeetcodeProblems/Algorithms/Clone_Graph.js) | Medium | https://leetcode.com/problems/clone-graph/ | -| [Coin Change ](/LeetcodeProblems/Algorithms/Coin_Change.js) | Medium | https://leetcode.com/problems/coin-change/ | -| [Container With Most Water](/LeetcodeProblems/Algorithms/Container_With_Most_Water.js) | Medium | https://leetcode.com/problems/container-with-most-water/ | -| [Design Circular Deque ](/LeetcodeProblems/Algorithms/Design_Circular_Deque.js) | Medium | https://leetcode.com/problems/design-circular-deque/ -| [Escape The Ghosts](/LeetcodeProblems/Algorithms/Escape_The_Ghosts.js) | Medium | https://leetcode.com/problems/escape-the-ghosts/ | -| [Find All Anagrams in a String](/LeetcodeProblems/Algorithms/Find_Anagrams.js) | Medium | https://leetcode.com/problems/find-all-anagrams-in-a-string/ | -| [Generate Parenthesis ](/LeetcodeProblems/Algorithms/Generate_Parenthesis.js) | Medium | https://leetcode.com/problems/generate-parentheses | -| [Group Anagrams ](/LeetcodeProblems/Algorithms/Group_Anagrams.js) | Medium | https://leetcode.com/problems/group-anagrams/ -| [Kth Largest Element in an Array ](/LeetcodeProblems/Algorithms/Kth_Largest_Element_in_an_Array.js) | Medium | https://leetcode.com/problems/kth-largest-element-in-an-array/ | -| [Linked List Cycle II ](/LeetcodeProblems/Algorithms/Linked_List_Cycle_II.js) | Medium | https://leetcode.com/problems/linked-list-cycle-ii/ | -| [Longest Palindromic Substring ](/LeetcodeProblems/Algorithms/Longest_Palindromic_Substring.js) | Medium | https://leetcode.com/problems/longest-palindromic-substring/| -| [Longest Substring Without Reapeating Characters](/LeetcodeProblems/Algorithms/Longest_Substring.js) | Medium | https://leetcode.com/problems/longest-substring-without-repeating-characters| -| [Max Area Of Island ](/LeetcodeProblems/Algorithms/Max_Area_Of_Island.js) | Medium | https://leetcode.com/problems/max-area-of-island/ | -| [Max Consecutive Ones III ](/LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III.js) | Medium | https://leetcode.com/problems/max-consecutive-ones-iii | -| [Maximal Square ](/LeetcodeProblems/Algorithms/Maximal_Square.js) | Medium | https://leetcode.com/problems/maximal-square/ | -| [Minimum Add to Make Parentheses Valid ](/LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid.js) | Medium | https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/ | -| [Minimum Size Subarray](/LeetcodeProblems/Algorithms/Minimum_Size_Subarray.js) | Medium | https://leetcode.com/problems/minimum-size-subarray-sum | -| [Permutations ](/LeetcodeProblems/Algorithms/Permutations.js) | Medium | https://leetcode.com/problems/permutations/ | -| [Permutations II ](/LeetcodeProblems/Algorithms/Permutations_II.js) | Medium | https://leetcode.com/problems/permutations-ii/ | -| [Permutation in String](/LeetcodeProblems/Algorithms/Permutations_In_String.js) | Medium | https://leetcode.com/problems/permutation-in-string/ | -| [Permutations Without Duplicates ](/LeetcodeProblems/Algorithms/Permutations_Without_Duplicates.js) | Medium | https://leetcode.com/problems/permutations/ | -| [Restore IP Addresses ](/LeetcodeProblems/Algorithms/Restore_IP_Addresses.js) | Medium | https://leetcode.com/problems/restore-ip-addresses/ | -| [SearchIng Rotated Sorted Array ](/LeetcodeProblems/Algorithms/SearchIng_Rotated_Sorted_Array.js) | Medium | https://leetcode.com/problems/search-in-rotated-sorted-array/ | -| [Search a 2D Matrix ](/LeetcodeProblems/Algorithms/Search_a_2D_Matrix.js) | Medium | https://leetcode.com/problems/search-a-2d-matrix/ | -| [Search a 2D Matrix II ](/LeetcodeProblems/Algorithms/Search_a_2D_Matrix_II.js) | Medium | https://leetcode.com/problems/search-a-2d-matrix/ | -| [Simplify Path ](/LeetcodeProblems/Algorithms/Simplify_Path.js) | Medium | https://leetcode.com/problems/simplify-path/ | -| [Spiral Matrix ](/LeetcodeProblems/Algorithms/Spiral_Matrix.js) | Medium | https://leetcode.com/problems/spiral-matrix/ | -| [Subsets ](/LeetcodeProblems/Algorithms/Subsets.js) | Medium | https://leetcode.com/problems/subsets/ | -| [Unique Binary Search Trees ](/LeetcodeProblems/Algorithms/Unique_Binary_Search_Trees.js) | Medium | https://leetcode.com/problems/unique-binary-search-trees/ | -| [Unique Paths ](/LeetcodeProblems/Algorithms/Unique_Paths.js) | Medium | https://leetcode.com/problems/unique-paths/ | -| [Verify Preorder Serialization of a Binary Tree ](/LeetcodeProblems/Algorithms/Verify_Preorder_Serialization_of_a_Binary_Tree.js) | Medium | https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/ | -| [Construct Binary Tree from Preorder and Inorder Traversal ](/LeetcodeProblems/Algorithms/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js) | Medium | https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ | -| [Lowest Common Ancestor of a Binary Tree ](/LeetcodeProblems/Algorithms/Lowest_Common_Ancestor_of_a_Binary_Tree.js) | Medium | https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ | -| [Maximum Sum of an Hourglass](/LeetcodeProblems/Algorithms/Maximise_Hour_Glass_Sum.js) | Medium | https://leetcode.com/problems/maximum-sum-of-an-hourglass/ | -| [Next Permutation](/LeetcodeProblems/Algorithms/Next_Permutation.js) | Medium | https://leetcode.com/problems/next-permutation/ | -| [Time Needed to Rearrange a Binary String](/LeetcodeProblems/Algorithms/Time_Needed_Rearrange_Binary_String.js)| Medium | https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/ | -| [Find Subarrays With Equal Sum ](/LeetcodeProblems/Algorithms/Find_Subarrays_With_Equal_Sums.js) | Medium | https://leetcode.com/problems/find-subarrays-with-equal-sum/ | -| [Reverse Integer](/LeetcodeProblems/Algorithms/Reverse_Integer.js) | Medium | https://leetcode.com/problems/reverse-integer/ | -| [Minimize Maximum Pair Sum in Array ](/LeetcodeProblems/Algorithms/Minimize_Maximum_Pair_Sum_In_Array.js) | Medium | https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/ | -| [Top K Frequent Elements ](/LeetcodeProblems/Algorithms/Top_K_Frequent_Elements.js) | Medium | https://leetcode.com/problems/top-k-frequent-elements/ | -| [Gas Station](/LeetcodeProblems/Algorithms/GasStation/index.js) | Medium | https://leetcode.com/problems/gas-station/description/| -| [K Closest Points to Origin](/LeetcodeProblems/Algorithms/K_Closest_Points_to_Origin.js/) | Medium | https://leetcode.com/problems/k-closest-points-to-origin/ -| [Flood Fill ](/LeetcodeProblems/Algorithms/Flood_Fill.js) | Easy | https://leetcode.com/problems/flood-fill/ | -| [Implement stack using queues ](/LeetcodeProblems/Algorithms/Implement_stack_using_queues.js) | Easy | https://leetcode.com/problems/implement-stack-using-queues/ | -| [Number of Segments in a String ](/LeetcodeProblems/Algorithms/Number_of_Segments_in_a_String.js) | Easy | https://leetcode.com/problems/number-of-segments-in-a-string/ | -| [Maximun Subarray ](/LeetcodeProblems/Algorithms/Maximun_Subarray.js) | Easy | https://leetcode.com/problems/maximum-subarray | -| [Min Stack ](/LeetcodeProblems/Algorithms/Min_Stack.js) | Easy | https://leetcode.com/problems/min-stack/ | -| [Reverse String II ](/LeetcodeProblems/Algorithms/Reverse_String_II.js) | Easy | https://leetcode.com/problems/reverse-string-ii/ | -| [Same Tree ](/LeetcodeProblems/Algorithms/Same_Tree.js) | Easy | https://leetcode.com/problems/same-tree/ | -| [Sum Of Square Numbers ](/LeetcodeProblems/Algorithms/Sum_Of_Square_Numbers.js) | Easy | https://leetcode.com/problems/sum-of-square-numbers/ | -| [Symmetric Tree ](/LeetcodeProblems/Algorithms/Symmetric_Tree.js) | Easy | https://leetcode.com/problems/symmetric-tree/ | -| [Valid Parentheses ](/LeetcodeProblems/Algorithms/Valid_Parentheses.js) | Easy | https://leetcode.com/problems/valid-parentheses/ | -| [Backspace String Compare ](/LeetcodeProblems/Algorithms/Backspace_String_Compare.js) | Easy | https://leetcode.com/problems/backspace-string-compare/ | -| [Binary Gap ](/LeetcodeProblems/Algorithms/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ | -| [Binary Gap ](/LeetcodeProblems/Algorithms/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ | -| [Majority Element](/LeetcodeProblems/Algorithms/Majority_Element.js) | Easy | https://leetcode.com/problems/majority-element/ | -| [Longest Common Prefix](/LeetcodeProblems/Algorithms/Longest_Common_Prefix.js) | Easy | https://leetcode.com/problems/longest-common-prefix/ | -| [Two Sum](/LeetcodeProblems/Algorithms/2Sum.js) | Easy | https://leetcode.com/problems/two-sum/ | -| [Tic Tac Toe ](/LeetcodeProblems/Algorithms/Tic_Tac_Toe.js) | | | -| [Permutations With Duplicates ](/LeetcodeProblems/Algorithms/Permutations_With_Duplicates.js) | | | -| [Deletion Distance](/LeetcodeProblems/Algorithms/Deletion_Distance.js) | | | -| [Award Budget Cuts](/LeetcodeProblems/Algorithms/Award_Budget_Cuts.js) | | | -| [Happy Number](https://leetcode.com/problems/happy-number/) | Easy | https://leetcode.com/problems/happy-number/ | -| [Shuffle String](https://leetcode.com/problems/shuffle-string/) | Easy | https://leetcode.com/problems/shuffle-string/ | +| [Edit Distance ](/LeetcodeProblems/Algorithms/hard/Edit_Distance.js) | Hard | https://leetcode.com/problems/edit-distance/ | +| [Remove Invalid Parentheses ](/LeetcodeProblems/Algorithms/hard/Remove_Invalid_Parentheses.js) | Hard | https://leetcode.com/problems/remove-invalid-parentheses/ | +| [Longest Consecutive Sequence ](/LeetcodeProblems/Algorithms/hard/Longest_Consecutive_Sequence.js) | Hard | https://leetcode.com/problems/longest-consecutive-sequence/ | +| [Minimum Window Substring ](/LeetcodeProblems/Algorithms/hard/Minimum_Window_Substring.js) | Hard | https://leetcode.com/problems/minimum-window-substring/ | +| [Regular Expression Matching ](/LeetcodeProblems/Algorithms/hard/Regular_Expression_Matching.js) | Hard | https://leetcode.com/problems/regular-expression-matching/ | +| [NQueens ](/LeetcodeProblems/Algorithms/hard/NQueens.js) | Hard | https://leetcode.com/problems/n-queens/ | +| [merge k sorted lists ](/LeetcodeProblems/Algorithms/hard/merge_k_sorted_lists.js) | Hard | https://leetcode.com/problems/merge-k-sorted-lists/ | +| [Set Matrix Zeroes](/LeetcodeProblems/Algorithms/hard/Set_Matrix_Zeroes.js) | Hard | https://leetcode.com/problems/set-matrix-zeroes/ | +| [Subarray Sum Equals K ](/LeetcodeProblems/Algorithms/medium/Subarray_Sum_Equals_K.js) | Medium | https://leetcode.com/problems/subarray-sum-equals-k/ | +| [3Sum Closest](/LeetcodeProblems/Algorithms/medium/3SumClosest.js) | Medium | https://leetcode.com/problems/3sum-closest/ | +| [3Sum ](/LeetcodeProblems/Algorithms/medium/3Sum.js) | Medium | https://leetcode.com/problems/3sum/ | +| [NumberOfIslands ](/LeetcodeProblems/Algorithms/medium/Number_of_Islands.js) | Medium | https://leetcode.com/problems/number-of-islands/ | +| [Swap Nodes in Pairs](/LeetcodeProblems/Algorithms/medium/Swap_Nodes_in_Pairs.js) | Medium | https://leetcode.com/problems/swap-nodes-in-pairs/ | +| [Add Two Numbers ](/LeetcodeProblems/Algorithms/medium/Add_Two_Numbers.js) | Medium | https://leetcode.com/problems/add-two-numbers/ | +| [Clone Graph ](/LeetcodeProblems/Algorithms/medium/Clone_Graph.js) | Medium | https://leetcode.com/problems/clone-graph/ | +| [Coin Change ](/LeetcodeProblems/Algorithms/medium/Coin_Change.js) | Medium | https://leetcode.com/problems/coin-change/ | +| [Container With Most Water](/LeetcodeProblems/Algorithms/medium/Container_With_Most_Water.js) | Medium | https://leetcode.com/problems/container-with-most-water/ | +| [Design Circular Deque ](/LeetcodeProblems/Algorithms/medium/Design_Circular_Deque.js) | Medium | https://leetcode.com/problems/design-circular-deque/ +| [Escape The Ghosts](/LeetcodeProblems/Algorithms/medium/Escape_The_Ghosts.js) | Medium | https://leetcode.com/problems/escape-the-ghosts/ | +| [Find All Anagrams in a String](/LeetcodeProblems/Algorithms/medium/Find_Anagrams.js) | Medium | https://leetcode.com/problems/find-all-anagrams-in-a-string/ | +| [Generate Parenthesis ](/LeetcodeProblems/Algorithms/medium/Generate_Parenthesis.js) | Medium | https://leetcode.com/problems/generate-parentheses | +| [Group Anagrams ](/LeetcodeProblems/Algorithms/medium/Group_Anagrams.js) | Medium | https://leetcode.com/problems/group-anagrams/ +| [Kth Largest Element in an Array ](/LeetcodeProblems/Algorithms/medium/Kth_Largest_Element_in_an_Array.js) | Medium | https://leetcode.com/problems/kth-largest-element-in-an-array/ | +| [Linked List Cycle II ](/LeetcodeProblems/Algorithms/medium/Linked_List_Cycle_II.js) | Medium | https://leetcode.com/problems/linked-list-cycle-ii/ | +| [Longest Palindromic Substring ](/LeetcodeProblems/Algorithms/medium/Longest_Palindromic_Substring.js) | Medium | https://leetcode.com/problems/longest-palindromic-substring/| +| [Longest Substring Without Reapeating Characters](/LeetcodeProblems/Algorithms/medium/Longest_Substring.js) | Medium | https://leetcode.com/problems/longest-substring-without-repeating-characters| +| [Max Area Of Island ](/LeetcodeProblems/Algorithms/medium/Max_Area_Of_Island.js) | Medium | https://leetcode.com/problems/max-area-of-island/ | +| [Max Consecutive Ones III ](/LeetcodeProblems/Algorithms/medium/Max_Consecutive_Ones_III.js) | Medium | https://leetcode.com/problems/max-consecutive-ones-iii | +| [Maximal Square ](/LeetcodeProblems/Algorithms/medium/Maximal_Square.js) | Medium | https://leetcode.com/problems/maximal-square/ | +| [Minimum Add to Make Parentheses Valid ](/LeetcodeProblems/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid.js) | Medium | https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/ | +| [Minimum Size Subarray](/LeetcodeProblems/Algorithms/medium/Minimum_Size_Subarray.js) | Medium | https://leetcode.com/problems/minimum-size-subarray-sum | +| [Permutations ](/LeetcodeProblems/Algorithms/medium/Permutations.js) | Medium | https://leetcode.com/problems/permutations/ | +| [Permutations II ](/LeetcodeProblems/Algorithms/medium/Permutations_II.js) | Medium | https://leetcode.com/problems/permutations-ii/ | +| [Permutation in String](/LeetcodeProblems/Algorithms/medium/Permutations_In_String.js) | Medium | https://leetcode.com/problems/permutation-in-string/ | +| [Permutations Without Duplicates ](/LeetcodeProblems/Algorithms/medium/Permutations_Without_Duplicates.js) | Medium | https://leetcode.com/problems/permutations/ | +| [Restore IP Addresses ](/LeetcodeProblems/Algorithms/medium/Restore_IP_Addresses.js) | Medium | https://leetcode.com/problems/restore-ip-addresses/ | +| [SearchIng Rotated Sorted Array ](/LeetcodeProblems/Algorithms/medium/SearchIng_Rotated_Sorted_Array.js) | Medium | https://leetcode.com/problems/search-in-rotated-sorted-array/ | +| [Search a 2D Matrix ](/LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix.js) | Medium | https://leetcode.com/problems/search-a-2d-matrix/ | +| [Search a 2D Matrix II ](/LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix_II.js) | Medium | https://leetcode.com/problems/search-a-2d-matrix/ | +| [Simplify Path ](/LeetcodeProblems/Algorithms/medium/Simplify_Path.js) | Medium | https://leetcode.com/problems/simplify-path/ | +| [Spiral Matrix ](/LeetcodeProblems/Algorithms/medium/Spiral_Matrix.js) | Medium | https://leetcode.com/problems/spiral-matrix/ | +| [Subsets ](/LeetcodeProblems/Algorithms/medium/Subsets.js) | Medium | https://leetcode.com/problems/subsets/ | +| [Unique Binary Search Trees ](/LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees.js) | Medium | https://leetcode.com/problems/unique-binary-search-trees/ | +| [Unique Paths ](/LeetcodeProblems/Algorithms/medium/Unique_Paths.js) | Medium | https://leetcode.com/problems/unique-paths/ | +| [Verify Preorder Serialization of a Binary Tree ](/LeetcodeProblems/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree.js) | Medium | https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/ | +| [Construct Binary Tree from Preorder and Inorder Traversal ](/LeetcodeProblems/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js) | Medium | https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ | +| [Lowest Common Ancestor of a Binary Tree ](/LeetcodeProblems/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree.js) | Medium | https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ | +| [Maximum Sum of an Hourglass](/LeetcodeProblems/Algorithms/medium/Maximise_Hour_Glass_Sum.js) | Medium | https://leetcode.com/problems/maximum-sum-of-an-hourglass/ | +| [Next Permutation](/LeetcodeProblems/Algorithms/medium/Next_Permutation.js) | Medium | https://leetcode.com/problems/next-permutation/ | +| [Time Needed to Rearrange a Binary String](/LeetcodeProblems/Algorithms/medium/Time_Needed_Rearrange_Binary_String.js)| Medium | https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/ | +| [Find Subarrays With Equal Sum ](/LeetcodeProblems/Algorithms/medium/Find_Subarrays_With_Equal_Sums.js) | Medium | https://leetcode.com/problems/find-subarrays-with-equal-sum/ | +| [Reverse Integer](/LeetcodeProblems/Algorithms/medium/Reverse_Integer.js) | Medium | https://leetcode.com/problems/reverse-integer/ | +| [Minimize Maximum Pair Sum in Array ](/LeetcodeProblems/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array.js) | Medium | https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/ | +| [Top K Frequent Elements ](/LeetcodeProblems/Algorithms/medium/Top_K_Frequent_Elements.js) | Medium | https://leetcode.com/problems/top-k-frequent-elements/ | +| [Gas Station](/LeetcodeProblems/Algorithms/medium/GasStation/index.js) | Medium | https://leetcode.com/problems/gas-station/description/| +| [K Closest Points to Origin](/LeetcodeProblems/Algorithms/medium/K_Closest_Points_to_Origin.js/) | Medium | https://leetcode.com/problems/k-closest-points-to-origin/ +| [BestTimeToBuy](LeetcodeProblems/Algorithms/easy/Best_Time_To_Buy_And_Sell_Stock_II.js) | Medium | https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii | +| [Flood Fill ](/LeetcodeProblems/Algorithms/easy/Flood_Fill.js) | Easy | https://leetcode.com/problems/flood-fill/ | +| [Implement stack using queues ](/LeetcodeProblems/Algorithms/easy/Implement_stack_using_queues.js) | Easy | https://leetcode.com/problems/implement-stack-using-queues/ | +| [Number of Segments in a String ](/LeetcodeProblems/Algorithms/easy/Number_of_Segments_in_a_String.js) | Easy | https://leetcode.com/problems/number-of-segments-in-a-string/ | +| [Maximun Subarray ](/LeetcodeProblems/Algorithms/easy/Maximun_Subarray.js) | Easy | https://leetcode.com/problems/maximum-subarray | +| [Min Stack ](/LeetcodeProblems/Algorithms/easy/Min_Stack.js) | Easy | https://leetcode.com/problems/min-stack/ | +| [Reverse String II ](/LeetcodeProblems/Algorithms/easy/Reverse_String_II.js) | Easy | https://leetcode.com/problems/reverse-string-ii/ | +| [Same Tree ](/LeetcodeProblems/Algorithms/easy/Same_Tree.js) | Easy | https://leetcode.com/problems/same-tree/ | +| [Sum Of Square Numbers ](/LeetcodeProblems/Algorithms/easy/Sum_Of_Square_Numbers.js) | Easy | https://leetcode.com/problems/sum-of-square-numbers/ | +| [Symmetric Tree ](/LeetcodeProblems/Algorithms/easy/Symmetric_Tree.js) | Easy | https://leetcode.com/problems/symmetric-tree/ | +| [Valid Parentheses ](/LeetcodeProblems/Algorithms/easy/Valid_Parentheses.js) | Easy | https://leetcode.com/problems/valid-parentheses/ | +| [Backspace String Compare ](/LeetcodeProblems/Algorithms/easy/Backspace_String_Compare.js) | Easy | https://leetcode.com/problems/backspace-string-compare/ | +| [Binary Gap ](/LeetcodeProblems/Algorithms/easy/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ | +| [Binary Gap ](/LeetcodeProblems/Algorithms/easy/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ | +| [Majority Element](/LeetcodeProblems/Algorithms/easy/Majority_Element.js) | Easy | https://leetcode.com/problems/majority-element/ | +| [Longest Common Prefix](/LeetcodeProblems/Algorithms/easy/Longest_Common_Prefix.js) | Easy | https://leetcode.com/problems/longest-common-prefix/ | +| [Two Sum](/LeetcodeProblems/Algorithms/easy/2Sum.js) | Easy | https://leetcode.com/problems/two-sum/ | +| [Tic Tac Toe ](/LeetcodeProblems/Algorithms/easy/Tic_Tac_Toe.js) | Easy | | +| [Permutations With Duplicates ](/LeetcodeProblems/Algorithms/easy/Permutations_With_Duplicates.js) | Easy | | +| [Deletion Distance](/LeetcodeProblems/Algorithms/easy/Deletion_Distance.js) | Easy | | +| [Award Budget Cuts](/LeetcodeProblems/Algorithms/easy/Award_Budget_Cuts.js) | Easy | | +| [Happy Number](/LeetcodeProblems/Algorithms/easy/Happy_Number.js) | Easy | https://leetcode.com/problems/happy-number/ | +| [Shuffle String](/LeetcodeProblems/Algorithms/easy/Shuffle_String.js) | Easy | https://leetcode.com/problems/shuffle-string/ | ### Sorting Algorithms | Algoritmhs | @@ -103,20 +104,20 @@ The solutions are located under `/LeetcodeProblems`. Each problem has a test fil ### Databases | Problems | Level | Link | |-|-|-| -| [Trips and Users](/LeetcodeProblems/Databases/Trips_and_Users.sql) | Hard | https://leetcode.com/problems/trips-and-users/ | -| [Human Traffic of Stadium](/LeetcodeProblems/Databases/Human_Traffic_of_Stadium.sql) | Hard | https://leetcode.com/problems/human-traffic-of-stadium | -| [Rank Scores](/LeetcodeProblems/Databases/Rank_Scores.sql) | Medium | https://leetcode.com/problems/rank-scores | -| [Consecutive Numbers](/LeetcodeProblems/Databases/Consecutive_Numbers.sql) | Medium | https://leetcode.com/problems/consecutive-numbers | -| [Department Highest Salary](/LeetcodeProblems/Databases/Department_Highest_Salary.sql) | Medium | https://leetcode.com/problems/department-highest-salary | -| [Exchange Seats](/LeetcodeProblems/Databases/Exchange_Seats.sql) | Medium | https://leetcode.com/problems/exchange-seats | -| [Nth Highest Salary](/LeetcodeProblems/Databases/nth_Highest_Salary.sql) | Medium | https://leetcode.com/problems/nth-highest-salary | -| [Combine Two Tables](/LeetcodeProblems/Databases/Combine_Two_Tables.sql) | Easy | https://leetcode.com/problems/combine-two-tables | -| [Second Highest Salary](/LeetcodeProblems/Databases/Second_highest_salary.sql)| Easy | https://leetcode.com/problems/second-highest-salary | -| [Customers Who Never Order](/LeetcodeProblems/Databases/Customers_Who_Never_Order.sql)| Easy | https://leetcode.com/problems/customers-who-never-order | -| [Reformat Department Table](/LeetcodeProblems/Databases/Reformat_Department_Table.sql) | Easy | https://leetcode.com/problems/reformat-department-table | -| [Employees Earning More Than Their Managers](/LeetcodeProblems/Databases/Employees_Earning_More_Than_Their_Managers.sql) | Easy | https://leetcode.com/problems/employees-earning-more-than-their-managers/ | -| [Delete Duplicate Emails](LeetcodeProblems/Databases/Delete_Duplicate_Emails.sql) | Easy | https://leetcode.com/problems/delete-duplicate-emails | -| [Rising Temperature](LeetcodeProblems/Databases/Rising_Temperature.sql) | Easy | https://leetcode.com/problems/rising-temperature | +| [Trips and Users](/LeetcodeProblems/Databases/hard/Trips_and_Users.sql) | Hard | https://leetcode.com/problems/trips-and-users/ | +| [Human Traffic of Stadium](/LeetcodeProblems/Databases/hard/Human_Traffic_of_Stadium.sql) | Hard | https://leetcode.com/problems/human-traffic-of-stadium | +| [Rank Scores](/LeetcodeProblems/Databases/medium/Rank_Scores.sql) | Medium | https://leetcode.com/problems/rank-scores | +| [Consecutive Numbers](/LeetcodeProblems/Databases/medium/Consecutive_Numbers.sql) | Medium | https://leetcode.com/problems/consecutive-numbers | +| [Department Highest Salary](/LeetcodeProblems/Databases/medium/Department_Highest_Salary.sql) | Medium | https://leetcode.com/problems/department-highest-salary | +| [Exchange Seats](/LeetcodeProblems/Databases/medium/Exchange_Seats.sql) | Medium | https://leetcode.com/problems/exchange-seats | +| [Nth Highest Salary](/LeetcodeProblems/Databases/medium/nth_Highest_Salary.sql) | Medium | https://leetcode.com/problems/nth-highest-salary | +| [Combine Two Tables](/LeetcodeProblems/Databases/easy/Combine_Two_Tables.sql) | Easy | https://leetcode.com/problems/combine-two-tables | +| [Second Highest Salary](/LeetcodeProblems/Databases/easy/Second_highest_salary.sql)| Easy | https://leetcode.com/problems/second-highest-salary | +| [Customers Who Never Order](/LeetcodeProblems/Databases/easy/Customers_Who_Never_Order.sql)| Easy | https://leetcode.com/problems/customers-who-never-order | +| [Reformat Department Table](/LeetcodeProblems/Databases/easy/Reformat_Department_Table.sql) | Easy | https://leetcode.com/problems/reformat-department-table | +| [Employees Earning More Than Their Managers](/LeetcodeProblems/Databases/easy/Employees_Earning_More_Than_Their_Managers.sql) | Easy | https://leetcode.com/problems/employees-earning-more-than-their-managers/ | +| [Delete Duplicate Emails](LeetcodeProblems/Databases/easy/Delete_Duplicate_Emails.sql) | Easy | https://leetcode.com/problems/delete-duplicate-emails | +| [Rising Temperature](LeetcodeProblems/Databases/easy/Rising_Temperature.sql) | Easy | https://leetcode.com/problems/rising-temperature | ### UtilsClasses diff --git a/Test.js b/Test.js index 27850e4..f96160f 100644 --- a/Test.js +++ b/Test.js @@ -2,39 +2,64 @@ /* eslint-disable no-undef */ const fs = require("fs"); -const TESTS_FOLDER = "./LeetcodeProblemsTests/Algorithms/"; +const TESTS_FOLDERS = [ + "./LeetcodeProblemsTests/Algorithms/easy/", + "./LeetcodeProblemsTests/Algorithms/medium/", + "./LeetcodeProblemsTests/Algorithms/hard/" +] + const REGEX_PATTERN_HIDDEN_FILES = /(^|\/)\.[^\/\.]/g; var test_all = async function () { try { - const problems = await loadProblems(); - for (i in problems) { - console.log("Solving: " + problems[i]); - const tests = require(TESTS_FOLDER + problems[i]); - if (Object.keys(tests).length == 0) { - console.warn("🔴 The problem " + problems[i] + " doesn't have a test method implemented.\n"); - continue; - } - for(testIdx in tests) { - tests[testIdx](); - } - console.log("✅ Tests for " + problems[i] + " run successfully \n"); - } + var problems = []; + for(const i in TESTS_FOLDERS) { + var folder = TESTS_FOLDERS[i]; + var new_problems = await loadProblemsFiles(folder); // await + problems = problems.concat(new_problems); + }; + console.log(problems); + + var solvePromises = problems.map(solve); + + await Promise.all(solvePromises) } catch (error) { + console.log(error); throw new Error(error); } }; -var loadProblems = () => { +var solve = (problem) => { + try { + console.log("Solving: " + problem); + + const tests = require(problem); + console.log("*" * 100); + if (Object.keys(tests).length == 0) { + console.warn("🔴 The problem " + problem + " doesn't have a test method implemented.\n"); + return; + } + for(testIdx in tests) { + tests[testIdx](); + } + console.log("✅ Tests for " + problem + " run successfully \n"); + } catch (error) { + console.log(error); + throw new Error(error); + } +} + +var loadProblemsFiles = (folder) => { return new Promise(function (resolve, reject) { - fs.readdir(TESTS_FOLDER, (error, files) => { + fs.readdir(folder, (error, files) => { if (error) { reject(error); } else { - problems = files.filter( - (item) => !REGEX_PATTERN_HIDDEN_FILES.test(item) - ); - resolve(problems); + console.log(folder); + new_problems = files.filter((item) => !REGEX_PATTERN_HIDDEN_FILES.test(item)); + new_problems = new_problems.map((item) => folder + item); + + resolve(new_problems); } }); });