diff --git a/.gitignore b/.gitignore index 97cf9d3..e5b4e82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ tips .DS_Store -node_modules/ \ No newline at end of file +node_modules/ + +JAVASCRIPT.md diff --git a/LeetcodeProblems/Algorithms/3SumClosest.js b/LeetcodeProblems/Algorithms/3SumClosest.js new file mode 100644 index 0000000..271821a --- /dev/null +++ b/LeetcodeProblems/Algorithms/3SumClosest.js @@ -0,0 +1,63 @@ +/* +3Sum Closest +https://leetcode.com/problems/3sum-closest/ + +Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. + +Return the sum of the three integers. + +You may assume that each input would have exactly one solution. + +Example 1: + +Input: nums = [-1,2,1,-4], target = 1 +Output: 2 +Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). +Example 2: + +Input: nums = [0,0,0], target = 1 +Output: 0 + + +Constraints: + +3 <= nums.length <= 1000 +-1000 <= nums[i] <= 1000 +-104 <= target <= 104 +*/ +/** + * @param {number[]} nums + * @param {number} target + * @return {number} + */ + var threeSumClosest = function(nums, target) { + let mid = 1; + let right = nums.length - 1; + let currentSum = nums[0] + nums[mid] + nums[right]; + let closest = currentSum; + + nums.sort(function(a,b) {return a - b}) + + for(var left = 0 ; left < nums.length - 1; left++) { + mid = left + 1; + right = nums.length - 1; + + while(mid < right) { + currentSum = nums[left] + nums[mid] + nums[right]; + + if(Math.abs(target - currentSum) < Math.abs(target - closest)) { + closest = currentSum; + } + + if(currentSum > target) { + right--; + } else { + mid++; + } + } + } + + return closest; +}; + +module.exports.threeSumClosest = threeSumClosest; \ No newline at end of file diff --git a/LeetcodeProblems/Algorithms/Container_With_Most_Water.js b/LeetcodeProblems/Algorithms/Container_With_Most_Water.js new file mode 100644 index 0000000..4b6098f --- /dev/null +++ b/LeetcodeProblems/Algorithms/Container_With_Most_Water.js @@ -0,0 +1,49 @@ +/* +Container With Most Water +https://leetcode.com/problems/container-with-most-water/ + +You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). + +Find two lines that together with the x-axis form a container, such that the container contains the most water. + +Return the maximum amount of water a container can store. + +Notice that you may not slant the container. + +Example 1: +Input: height = [1,8,6,2,5,4,8,3,7] +Output: 49 +Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49. +Example 2: + +Input: height = [1,1] +Output: 1 +*/ + +/** + * @param {number[]} height + * @return {number} + */ + var maxArea = function(height) { + let left = 0; + let right = height.length - 1; + let maxArea = calculateArea(left, right, height); + + while(left < right) { + if(height[left] < height[right]) { + left++ + } else { + right--; + } + maxArea = Math.max(maxArea, calculateArea(left, right, height)) + } + return maxArea; +}; + +var calculateArea = function(x, y, height) { + let minHeight = height[x] > height[y] ? height[y] : height[x]; + let width = y -x; + return (width * minHeight); +} + +module.exports.maxArea = maxArea; \ No newline at end of file diff --git a/LeetcodeProblems/Algorithms/Find_Anagrams.js b/LeetcodeProblems/Algorithms/Find_Anagrams.js new file mode 100644 index 0000000..1d201b0 --- /dev/null +++ b/LeetcodeProblems/Algorithms/Find_Anagrams.js @@ -0,0 +1,83 @@ +/* +Find All Anagrams in a String +https://leetcode.com/problems/find-all-anagrams-in-a-string/ + +Given two strings s and p, return an array of all the start indices of p's anagrams in s. +You may return the answer in any order. + +An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, +ypically using all the original letters exactly once. + +Example 1: + +Input: s = "cbaebabacd", p = "abc" +Output: [0,6] +Explanation: +The substring with start index = 0 is "cba", which is an anagram of "abc". +The substring with start index = 6 is "bac", which is an anagram of "abc". +Example 2: + +Input: s = "abab", p = "ab" +Output: [0,1,2] +Explanation: +The substring with start index = 0 is "ab", which is an anagram of "ab". +The substring with start index = 1 is "ba", which is an anagram of "ab". +The substring with start index = 2 is "ab", which is an anagram of "ab". +*/ + +/** + * @param {string} s + * @param {string} p + * @return {number[]} + */ + var findAnagrams = function(s, p) { + if(s.length < p.length) { return [] } + + let start = 0; + let end = p.length - 1; + let hashBuild = {}; + let countLeft = p.length; + let anagrams = [] + + for(let e = 0; e < p.length; e++) { + hashBuild[p[e]] = hashBuild[p[e]] !== undefined ? hashBuild[p[e]] + 1 : 1; + } + + for(let i = start; i < end; i++) { + if(hashBuild[s[i]] !== undefined) { + hashBuild[s[i]] = hashBuild[s[i]] - 1; + if(hashBuild[s[i]] >= 0) { + countLeft--; + } + } + } + + while(end < s.length) { + // check left + if(hashBuild[s[end]] !== undefined) { + hashBuild[s[end]] = hashBuild[s[end]] - 1; + if(hashBuild[s[end]] >= 0) { + countLeft--; + } + if(countLeft == 0) { + anagrams.push(start); + } + } + + // check right + if(hashBuild[s[start]] !== undefined) { + hashBuild[s[start]] = hashBuild[s[start]] + 1; + if(hashBuild[s[start]] >= 1) { + countLeft++; + } + } + + // slide window + end++; + start++; + } + + return anagrams; +}; + +module.exports.findAnagrams = findAnagrams; diff --git a/LeetcodeProblems/Algorithms/Longest_Substring.js b/LeetcodeProblems/Algorithms/Longest_Substring.js new file mode 100644 index 0000000..a6430f1 --- /dev/null +++ b/LeetcodeProblems/Algorithms/Longest_Substring.js @@ -0,0 +1,65 @@ +/* +Longest Substring Without Repeating Characters +https://leetcode.com/problems/longest-substring-without-repeating-characters + +Given a string s, find the length of the longest substring without repeating characters. + +Example 1: + +Input: s = "abcabcbb" +Output: 3 +Explanation: The answer is "abc", with the length of 3. +Example 2: + +Input: s = "bbbbb" +Output: 1 +Explanation: The answer is "b", with the length of 1. +Example 3: + +Input: s = "pwwkew" +Output: 3 +Explanation: The answer is "wke", with the length of 3. +Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. + + +Constraints: + +0 <= s.length <= 5 * 104 +s consists of English letters, digits, symbols and spaces. +*/ + +/** + * @param {string} s + * @return {number} + */ + var lengthOfLongestSubstring = function(s) { + if(s.length == 0) { return 0 } + + var repeatedChars = new Set(); + var maxLength = 1; + var currentMaxLength = 1; + var start = 0; + var end = 0; + repeatedChars.add(s.charAt(start)); + + while(end + 1 < s.length && start < s.length) { + if(repeatedChars.has(s.charAt(end + 1))) { + if(repeatedChars.has(s.charAt(start))) { + currentMaxLength--; + repeatedChars.delete(s.charAt(start)) + } + start++; + } else { + repeatedChars.add(s.charAt(end + 1)); + currentMaxLength++; + if(currentMaxLength > maxLength) { + maxLength = currentMaxLength; + } + end++; + } + } + + return maxLength; +}; + +module.exports.lengthOfLongestSubstring = lengthOfLongestSubstring; diff --git a/LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III.js b/LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III.js new file mode 100644 index 0000000..7766668 --- /dev/null +++ b/LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III.js @@ -0,0 +1,44 @@ +/* +Max Consecutive Ones III +https://leetcode.com/problems/max-consecutive-ones-iii + +Given a binary array nums and an integer k, return the maximum number of consecutive 1's +in the array if you can flip at most k 0's. + +Example 1: + +Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 +Output: 6 +Explanation: [1,1,1,0,0,1,1,1,1,1,1] +Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. +Example 2: + +Input: nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3 +Output: 10 +Explanation: [0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1] +Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. +*/ + +var longestOnes = function(nums, k) { + let start = 0; + let end = 0; + let maxWindow = 0; + while(start < nums.length && end < nums.length) { + if(k > 0 || nums[end] == 1) { + if(nums[end] == 0) { k--; } + maxWindow = Math.max(maxWindow, end - start + 1); + end++; + } else { // k = 0 and nums[end] == 0 + while(k == 0 && start < nums.length) { + if(nums[start] == 0) { + k++; + } + start++; + } + } + } + + return maxWindow; +}; + +module.exports.longestOnes = longestOnes; diff --git a/LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid.js b/LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid.js new file mode 100644 index 0000000..9181d20 --- /dev/null +++ b/LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid.js @@ -0,0 +1,69 @@ +/* +Minimum Add to Make Parentheses Valid +https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/ + +A parentheses string is valid if and only if: + +It is the empty string, +It can be written as AB (A concatenated with B), where A and B are valid strings, or +It can be written as (A), where A is a valid string. +You are given a parentheses string s. In one move, you can insert a parenthesis at any position of the string. + +For example, if s = "()))", you can insert an opening parenthesis to be "(()))" or a closing parenthesis to be "())))". +Return the minimum number of moves required to make s valid. + +Example 1: + +Input: s = "())" +Output: 1 +Example 2: + +Input: s = "(((" +Output: 3 + +Constraints: + +1 <= s.length <= 1000 +s[i] is either '(' or ')'. +*/ + + +var minAddToMakeValid = function(s) { + var opening = 0; + var extraParClosing = 0; + + for(let i = 0; i < s.length; i++) { + if(s.charAt(i) == "(") { + opening++; + } else if(s.charAt(i) == ")") { + if(opening == 0) { + extraParClosing++; + } else { + opening--;; + } + } + } + return extraParClosing + opening; +}; + +// Solution 2 using a queue +var minAddToMakeValidUsingQueue = function(s) { + var queue = []; + var extraParClosing = 0; + + for(let i = 0; i < s.length; i++) { + if(s.charAt(i) == "(") { + queue.push(s.charAt(i)) + } else if(s.charAt(i) == ")") { + if(queue.length > 0) { + queue.pop(); + } else { + extraParClosing++; + } + } + } + + return extraParClosing + queue.length; +}; + +module.exports.minAddToMakeValid = minAddToMakeValid; \ No newline at end of file diff --git a/LeetcodeProblems/Algorithms/Minimum_Size_Subarray.js b/LeetcodeProblems/Algorithms/Minimum_Size_Subarray.js new file mode 100644 index 0000000..dcaa489 --- /dev/null +++ b/LeetcodeProblems/Algorithms/Minimum_Size_Subarray.js @@ -0,0 +1,56 @@ +/* +https://leetcode.com/problems/minimum-size-subarray-sum + +Given an array of positive integers nums and a positive integer target, +return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] +of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead. + +Example 1: +Input: target = 7, nums = [2,3,1,2,4,3] +Output: 2 +Explanation: The subarray [4,3] has the minimal length under the problem constraint. + +Example 2: +Input: target = 4, nums = [1,4,4] +Output: 1 + +Example 3: +Input: target = 11, nums = [1,1,1,1,1,1,1,1] +Output: 0 +*/ + +/** + * @param {number} target + * @param {number[]} nums + * @return {number} + */ + var minSubArrayLength = function(target, nums) { + if(nums.length == 0) { return 0 } + + let start = 0; + let end = 0; + let currentSum = nums[0]; + let minWindow = 0; + let currentWindow = 1; + + while(start < nums.length && end < nums.length) { + currentWindow = (end + 1 - start) + if(currentSum >= target || (minWindow != 0 && currentWindow > minWindow) ) { + if(minWindow == 0 || minWindow > currentWindow ) { + minWindow = currentWindow; + if(minWindow == 1) { return 1 }; + } + currentSum -= nums[start]; + start++; + } else { + end++; + if(end < nums.length) { + currentSum += nums[end]; + } + } + } + + return minWindow; +}; + +module.exports.minSubArrayLength = minSubArrayLength; diff --git a/LeetcodeProblems/Algorithms/Permutations_In_String.js b/LeetcodeProblems/Algorithms/Permutations_In_String.js new file mode 100644 index 0000000..17ea56c --- /dev/null +++ b/LeetcodeProblems/Algorithms/Permutations_In_String.js @@ -0,0 +1,76 @@ +/* +Permutation in String +https://leetcode.com/problems/permutation-in-string/ + +Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. +In other words, return true if one of s1's permutations is the substring of s2. + +Example 1: + +Input: s1 = "ab", s2 = "eidbaooo" +Output: true +Explanation: s2 contains one permutation of s1 ("ba"). +Example 2: + +Input: s1 = "ab", s2 = "eidboaoo" +Output: false + +Constraints: +1 <= s1.length, s2.length <= 104 +s1 and s2 consist of lowercase English letters. +*/ + + +/** + * @param {string} s1 + * @param {string} s2 + * @return {boolean} + */ + var checkInclusion = function(s1, s2) { + if(s1.length > s2.length) { + return false + } + + let start = 0; + let end = s1.length - 1; + let countLeft = s1.length; + let hashBuild = {}; + + for(var i = 0; i < s1.length; i++) { + hashBuild[s1[i]] = (hashBuild[s1[i]] || 0) + 1; + } + + for(var j = start; j < end; j++) { // TODO: didn't count upper bound + if(hashBuild[s2[j]] !== undefined) { + hashBuild[s2[j]] = hashBuild[s2[j]] - 1; + if(hashBuild[s2[j]] >= 0) { + countLeft--; + } + } + } + + while(end < s2.length) { + if(hashBuild[s2[end]] !== undefined) { + hashBuild[s2[end]] = hashBuild[s2[end]] - 1; + if(hashBuild[s2[end]] >= 0) { + countLeft--; + } + } + + if(countLeft == 0) { return true } + + if(hashBuild[s2[start]] !== undefined) { + hashBuild[s2[start]] = hashBuild[s2[start]] + 1; + if(hashBuild[s2[start]] >= 1) { + countLeft++; + } + } + + start++; + end++; + } + + return false; +}; + +module.exports.checkInclusion = checkInclusion; \ No newline at end of file diff --git a/LeetcodeProblems/RESOURCES.md b/LeetcodeProblems/RESOURCES.md new file mode 100644 index 0000000..eee9491 --- /dev/null +++ b/LeetcodeProblems/RESOURCES.md @@ -0,0 +1,2 @@ +[Common Patters on Leetcode problems](https://iorilan.medium.com/after-solved-1000-medium-leetcode-found-these-patterns-sliding-window-2-pointer-string-18332ca4861) + diff --git a/LeetcodeProblemsTests/Algorithms/3Sum_Closest_Test.js b/LeetcodeProblemsTests/Algorithms/3Sum_Closest_Test.js new file mode 100644 index 0000000..af8e630 --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/3Sum_Closest_Test.js @@ -0,0 +1,10 @@ +const assert = require('assert'); +const threeSumClosest = require('../../LeetcodeProblems/Algorithms/3SumClosest').threeSumClosest; + +var test = function () { + assert.equal(2, threeSumClosest([-1, 2 , 1, -4], 1)); + assert.equal(0, threeSumClosest([0, 0, 0], 1)); + +} + +module.exports.test = test; diff --git a/LeetcodeProblemsTests/Algorithms/Container_With_Most_Water_Test.js b/LeetcodeProblemsTests/Algorithms/Container_With_Most_Water_Test.js new file mode 100644 index 0000000..4006962 --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Container_With_Most_Water_Test.js @@ -0,0 +1,10 @@ +const assert = require('assert'); +const maxArea = require('../../LeetcodeProblems/Algorithms/Container_With_Most_Water_Test').maxArea; + +function test() { + assert.equal(49, maxArea([1,8,6,2,5,4,8,3,7])); + assert.equal(1, maxArea([1,1])); + +} + +module.exports.test = test; \ No newline at end of file diff --git a/LeetcodeProblemsTests/Algorithms/Find_Anagrams_Test.js b/LeetcodeProblemsTests/Algorithms/Find_Anagrams_Test.js new file mode 100644 index 0000000..504e136 --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Find_Anagrams_Test.js @@ -0,0 +1,12 @@ + +const assert = require('assert'); +var findAnagrams = require('../../LeetcodeProblems/Algorithms/Find_Anagrams').findAnagrams; + +function test() { + assert.deepEqual([], findAnagrams("AA", "BB")); + assert.deepEqual([0,1,2,3], findAnagrams("AAAA", "A")); + assert.deepEqual([0,1,2], findAnagrams("abab", "ab")); + assert.deepEqual([0,6], findAnagrams("cbaebabacd", "abc")); +} + +module.exports.test = test; diff --git a/LeetcodeProblemsTests/Algorithms/Longest_Substring_Test.js b/LeetcodeProblemsTests/Algorithms/Longest_Substring_Test.js new file mode 100644 index 0000000..09c073e --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Longest_Substring_Test.js @@ -0,0 +1,12 @@ +const assert = require('assert'); +const lengthOfLongestSubstring = require('../../LeetcodeProblems/Algorithms/Longest_Substring').lengthOfLongestSubstring; + +function test() { + assert.equal(4, lengthOfLongestSubstring("abcdbcd")); + assert.equal(0, lengthOfLongestSubstring("")); + assert.equal(1, lengthOfLongestSubstring("b")); + assert.equal(1, lengthOfLongestSubstring("bb")); + assert.equal(3, lengthOfLongestSubstring("bbacb")); +} + +module.exports.test = test; diff --git a/LeetcodeProblemsTests/Algorithms/Max_Consecutive_Ones_III_Test.js b/LeetcodeProblemsTests/Algorithms/Max_Consecutive_Ones_III_Test.js new file mode 100644 index 0000000..96b6986 --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Max_Consecutive_Ones_III_Test.js @@ -0,0 +1,12 @@ +const assert = require('assert'); +const longestOnes = require('../../LeetcodeProblems/Algorithms/Max_Consecutive_Ones_III').longestOnes; + +function test() { + assert.equal(1, longestOnes([1], 1)); + assert.equal(1, longestOnes([0], 1)); + assert.equal(0, longestOnes([0], 0)); + assert.equal(6, longestOnes([1,1,1,0,0,0,1,1,1,1,0], 2)); + assert.equal(10, longestOnes([0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], 3)); +} + +module.exports.test = test; diff --git a/LeetcodeProblemsTests/Algorithms/Minimum_Add_To_Make_Parentheses_Valid_Test.js b/LeetcodeProblemsTests/Algorithms/Minimum_Add_To_Make_Parentheses_Valid_Test.js new file mode 100644 index 0000000..b175736 --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Minimum_Add_To_Make_Parentheses_Valid_Test.js @@ -0,0 +1,13 @@ +const assert = require('assert'); +const minAddToMakeValid = require('../../LeetcodeProblems/Algorithms/Minimum_Add_To_Make_Parentheses_Valid').minAddToMakeValid; + +var test = function() { + assert.strictEqual(1, minAddToMakeValid("()(")); + assert.strictEqual(3, minAddToMakeValid("(((")); + assert.strictEqual(0, minAddToMakeValid("()")); + assert.strictEqual(1, minAddToMakeValid(")")); + assert.strictEqual(1, minAddToMakeValid("(")); + assert.strictEqual(2, minAddToMakeValid(")(")); +}; + +module.exports.test = test; diff --git a/LeetcodeProblemsTests/Algorithms/Minimum_Size_Subarray_Test.js b/LeetcodeProblemsTests/Algorithms/Minimum_Size_Subarray_Test.js new file mode 100644 index 0000000..7d2c4d1 --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Minimum_Size_Subarray_Test.js @@ -0,0 +1,15 @@ +const assert = require('assert'); +const minSubArrayLength = require('../../LeetcodeProblems/Algorithms/Minimum_Size_Subarray').minSubArrayLength; + +function test() { + assert.equal(0, minSubArrayLength(10, [])); + assert.equal(0, minSubArrayLength(10, [4,1,2])); + assert.equal(2, minSubArrayLength(4, [1,1,1,1, 3, 1])); + assert.equal(1, minSubArrayLength(11, [5, 6, 12, 3, 1])); + assert.equal(5, minSubArrayLength(5, [1,1,1,1,1])); + assert.equal(2, minSubArrayLength(7, [2,3,1,2,4,3])); + assert.equal(1, minSubArrayLength(4, [1,4,4])); + assert.equal(0, minSubArrayLength(11, [1,1,1,1,1,1,1,1])); +} + +module.exports.test = test; diff --git a/LeetcodeProblemsTests/Algorithms/Permutations_In_String_Test.js b/LeetcodeProblemsTests/Algorithms/Permutations_In_String_Test.js new file mode 100644 index 0000000..33b4dbf --- /dev/null +++ b/LeetcodeProblemsTests/Algorithms/Permutations_In_String_Test.js @@ -0,0 +1,12 @@ +const assert = require('assert'); +const checkInclusion = require('../../LeetcodeProblems/Algorithms/Permutations_In_String').checkInclusion; + +function test() { + assert.equal(false, checkInclusion("abc", "ab")); + assert.equal(false, checkInclusion("aa", "aba")); + assert.equal(true, checkInclusion("ab", "eidbaooo")); + assert.equal(false, checkInclusion("ab", "eidboaoo")); +} +test(); + +module.exports.test = test; diff --git a/README.md b/README.md index e956988..83e0d23 100644 --- a/README.md +++ b/README.md @@ -23,23 +23,31 @@ To run a specific problem in your console run `node ` (e.g. | [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/ | +| [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/| -| [Max Area Of Island ](/LeetcodeProblems/Algorithms/Max_Area_Of_Island.js) | Medium | https://leetcode.com/problems/max-area-of-island/ | +| [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/ |