Skip to content

Commit

Permalink
Move problems to subfolders (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacio-chiazzo committed Oct 30, 2023
2 parents 3c0d8f4 + 21e9249 commit 21e198d
Show file tree
Hide file tree
Showing 174 changed files with 235 additions and 209 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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("))))(()"), "()");
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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([]), []);
Expand Down
Original file line number Diff line number Diff line change
@@ -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]);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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]));
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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]));
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Loading

0 comments on commit 21e198d

Please sign in to comment.