├── .gitignore ├── 1-100 ├── 1-two-sum.js ├── 20-valid-parentheses.js ├── 28-implement-strstr.js ├── 35-search-insert-position.js ├── 58-length-of-last-word.js ├── 7-reverse-integer.js └── 9-palindrome-number.js ├── 101-200 ├── 125-valid-palindrome.js ├── 167-two-sum-ii.js └── 169-majority-element.js ├── 1101-1200 ├── 1108-defang-ip-address.js └── 1185-day-f-week.js ├── 1201-1300 ├── 1252-cells-with-odd-values.js ├── 1281-subtract-product-sum-of-digits.js └── 1295-find-numbers-with-even-number-of-digits.js ├── 1301-1400 ├── 1313-decompress-run-length-encoded-list.js ├── 1342-reduce-numer-to-zero.js ├── 1365-how-many-numbers-smaller-than-current-number.js └── 1389-create-target-array-in-the-given-order.js ├── 201-300 ├── 205-isomorphic-strings.js ├── 217-contains-duplicate.js ├── 219-contains-duplicate-ii.js ├── 242-valid-anagram.js └── 268-missing-number.js ├── 301-400 ├── 344-reverse-string.js ├── 345-reverse-vowels-of-a-string.js ├── 349-intersection-of-two-arrays.js ├── 374-guess-number-higher-or-lower.js ├── 383-ransom-note.js └── 387-first-unique-character-in-a-string.js ├── 501-600 └── 509-fibonacci-number.js ├── 701-800 ├── 709-to-lower-case.js └── 771-jewels-and-stones.js ├── 801-900 └── 867-transpose-matrix.js ├── 901-1000 └── 929-unique-email-address.js ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | -------------------------------------------------------------------------------- /1-100/1-two-sum.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/two-sum/ 4 | blog for this code :- https://rishabh1403.com/leetcode-solution-of-two-sum-in-javascript 5 | youtube video :- https://www.youtube.com/watch?v=qqC9m93ofwI 6 | */ 7 | 8 | 9 | // two nested loops 10 | 11 | var twoSum = function (nums, target) { 12 | for (let i = 0; i < nums.length; i++) { 13 | for (let j = 0; j < nums.length; j++) { 14 | if(i !== j){ 15 | if (nums[i] + nums[j] === target) { 16 | return [i, j]; 17 | } 18 | } 19 | } 20 | } 21 | } 22 | 23 | // two nested loops with optimizations 24 | 25 | var twoSum = function (nums, target) { 26 | for (let i = 0; i < nums.length; i++) { 27 | for (let j = i + 1; j < nums.length; j++) { 28 | if (nums[i] + nums[j] === target) { 29 | return [i, j]; 30 | } 31 | } 32 | } 33 | } 34 | 35 | // one loop with hashmap 36 | 37 | var twoSum = function (nums, target) { 38 | let obj = {} 39 | for (let i = 0; i < nums.length; i++) { 40 | if (target - nums[i] in obj) { 41 | return [obj[target - nums[i]], i] 42 | } else { 43 | obj[nums[i]] = i; 44 | } 45 | } 46 | }; 47 | 48 | // two pointer method with missing edge cases 49 | 50 | var twoSum = function (nums, target) { 51 | const clone = [...nums]; 52 | nums.sort((a, b) => a - b); 53 | 54 | let low = 0, high = nums.length - 1; 55 | 56 | while (low < high) { 57 | if (nums[low] + nums[high] < target) { 58 | low++; 59 | } else if (nums[low] + nums[high] > target) { 60 | high--; 61 | } else { 62 | return [clone.indexOf(nums[low]), clone.indexOf(nums[high])]; 63 | } 64 | } 65 | } 66 | 67 | // two pointer method, edge cases covered 68 | 69 | var twoSum = function (nums, target) { 70 | const clone = [...nums]; 71 | nums.sort((a, b) => a - b); 72 | let low = 0, high = nums.length - 1; 73 | while (low < high) { 74 | if (nums[low] + nums[high] < target) { 75 | low++; 76 | } else if (nums[low] + nums[high] > target) { 77 | high--; 78 | } else { 79 | if (nums[low] === nums[high]) { 80 | return [clone.indexOf(nums[low]), clone.indexOf(nums[high], clone.indexOf(nums[low]) + 1)]; 81 | } 82 | return [clone.indexOf(nums[low]), clone.indexOf(nums[high])]; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /1-100/20-valid-parentheses.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/valid-parentheses/ 4 | blog for this code :- 5 | https://rishabh1403.com/posts/coding/leetcode/2019/09/leetcode-solution-of-valid-parentheses-in-javascript 6 | youtube video :- https://youtu.be/OuRH74PiPas 7 | */ 8 | 9 | 10 | var isValid = function (s) { 11 | 12 | const obj = { 13 | "(": ")", 14 | "{": "}", 15 | "[": "]", 16 | } 17 | 18 | const stack = []; 19 | 20 | for (const paran of s) { 21 | if (obj.hasOwnProperty(paran)) { 22 | stack.push(paran) 23 | } else { 24 | const closeParan = stack.pop(); 25 | if (paran !== obj[closeParan]) { 26 | return false; 27 | } 28 | } 29 | } 30 | 31 | return stack.length === 0; 32 | }; -------------------------------------------------------------------------------- /1-100/28-implement-strstr.js: -------------------------------------------------------------------------------- 1 | /** 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/implement-strstr/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-implement-strstr 5 | youtube video :- https://youtu.be/pKa_2pLb3Rw 6 | */ 7 | 8 | var strStr = function (haystack, needle) { 9 | if (needle.length === 0) { 10 | return 0; 11 | } 12 | 13 | const haystackLength = haystack.length; 14 | const needleLength = needle.length; 15 | 16 | for (let i = 0; i <= haystackLength - needleLength; i++) { 17 | let flag = true; 18 | 19 | for (let j = i, k = 0; j < needleLength + i, k < needleLength; j++, k++) { 20 | if (haystack[j] !== needle[k]) { 21 | flag = false; 22 | break; 23 | } 24 | } 25 | 26 | if (flag) { 27 | return i; 28 | } 29 | } 30 | return -1; 31 | }; 32 | 33 | 34 | //////////////////////////// 35 | 36 | var strStr = function (haystack, needle) { 37 | if (haystack === '' && needle === '') { 38 | return 0 39 | } 40 | if (needleLength > haystack.length) { 41 | return -1; 42 | } 43 | for (var i = 0; i < haystack.length - needle.length + 1; i++) { 44 | if (haystack.slice(i, i + needle.length) === needle) { 45 | return i 46 | } 47 | } 48 | return -1 49 | 50 | }; 51 | 52 | ////////////////////////////// 53 | // Other Algos that can be used 54 | // KMP 55 | // Robin karp -------------------------------------------------------------------------------- /1-100/35-search-insert-position.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/search-insert-position/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-search-insert-position 5 | youtube video :- https://youtu.be/l2XPvyTlC6c 6 | */ 7 | 8 | var searchInsert = function (nums, target) { 9 | 10 | for (let index = 0; index < nums.length; index++) { 11 | if (target <= nums[index]) { 12 | return index; 13 | } 14 | } 15 | return nums.length; 16 | }; -------------------------------------------------------------------------------- /1-100/58-length-of-last-word.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/length-of-last-word/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-length-of-last-word 5 | youtube video :- https://youtu.be/2PQ4vtnLfnw 6 | */ 7 | 8 | // library methods 9 | 10 | var lengthOfLastWord = function (s) { 11 | const words = s.trim().split(" "); 12 | 13 | if (words.length < 1) { 14 | return 0; 15 | } 16 | 17 | return words[words.length - 1].length; 18 | }; 19 | 20 | // Back traversal 21 | 22 | var lengthOfLastWord = function (s) { 23 | let len = 0; 24 | let hasStarted = false; 25 | 26 | for (let i = s.length - 1; i >= 0; i--) { 27 | if (s[i] !== ' ') { 28 | hasStarted = true; 29 | } 30 | 31 | if (hasStarted) { 32 | if (s[i] === ' ') { 33 | break; 34 | } 35 | 36 | len++; 37 | } 38 | } 39 | return len; 40 | }; 41 | 42 | // Back traversal with library menthods 43 | 44 | var lengthOfLastWord = function (s) { 45 | s = ' ' + s.trim(); 46 | return s.length - s.lastIndexOf(' ') - 1; 47 | }; 48 | 49 | 50 | // regex 51 | 52 | var lengthOfLastWord = function (s) { 53 | return (s.match(/(\w+)\s*$/) || [, ''])[1].length; 54 | }; 55 | -------------------------------------------------------------------------------- /1-100/7-reverse-integer.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/reverse-integer/ 4 | blog for this code :- https://rishabh1403.com/leetcode-solution-of-reverse-integer-in-javascript 5 | youtube video :- https://www.youtube.com/watch?v=cIBwTqjh6VQ 6 | 7 | */ 8 | 9 | 10 | // string based method 11 | 12 | var reverse = function (x) { 13 | 14 | const reversedInt = parseInt(Math.abs(x).toString().split('').reverse().join('')); 15 | 16 | if (reversedInt > 2 ** 31) return 0; 17 | 18 | return reversedInt * Math.sign(x); 19 | 20 | }; 21 | 22 | // string based method without explicit type casting 23 | 24 | var reverse = function (x) { 25 | 26 | const reversedInt = Math.abs(x).toString().split('').reverse().join(''); 27 | 28 | if (reversedInt > 2 ** 31) return 0; 29 | 30 | return reversedInt * Math.sign(x); 31 | 32 | }; 33 | 34 | // integer based method 35 | 36 | var reverse = function (x) { 37 | const isNegative = x < 0 ? true : false; 38 | 39 | if (isNegative) { 40 | x = x * -1; 41 | } 42 | 43 | let reversed = 0; 44 | while (x > 0) { 45 | reversed = (reversed * 10) + (x % 10); 46 | 47 | x = parseInt(x / 10); 48 | } 49 | 50 | if (reversed > 2 ** 31) { 51 | return 0; 52 | } 53 | 54 | return isNegative ? reversed * -1 : reversed; 55 | }; -------------------------------------------------------------------------------- /1-100/9-palindrome-number.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/palindrome-number/ 4 | blog for this code :- https://rishabh1403.com/leetcode-solution-of-palindrome-number-in-javascript 5 | youtube video :- https://youtu.be/7lCkkX3UAvU 6 | */ 7 | 8 | 9 | 10 | // string based implementation 11 | 12 | var isPalindrome = function (x) { 13 | return x == x.toString().split('').reverse().join(''); 14 | }; 15 | 16 | // number based implementation 17 | 18 | var isPalindrome = function (x) { 19 | const isNegative = x < 0 ? true : false; 20 | 21 | if (isNegative) { 22 | return false; 23 | } 24 | 25 | const temp = x; 26 | let reversed = 0; 27 | 28 | while (x > 0) { 29 | reversed = (reversed * 10) + (x % 10); 30 | x = parseInt(x / 10); 31 | } 32 | 33 | return reversed == temp; 34 | }; 35 | 36 | // two pointer method 37 | 38 | var isPalindrome = function (x) { 39 | 40 | if (x < 0) { 41 | return false; 42 | } 43 | 44 | if (x < 10) { 45 | return true; 46 | } 47 | 48 | if (x % 10 === 0 && x !== 0) { 49 | return false; 50 | } 51 | 52 | const str = String(x); 53 | let i = 0, j = str.length - 1; 54 | 55 | while (i < j) { 56 | if (str[i] !== str[j]) { 57 | return false; 58 | } 59 | 60 | i++; 61 | j--; 62 | } 63 | 64 | return true; 65 | }; -------------------------------------------------------------------------------- /101-200/125-valid-palindrome.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/valid-palindrome/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-valid-palindrome 5 | youtube video :- https://youtu.be/zqQRjBbwRew 6 | */ 7 | 8 | var isPalindrome = function (s) { 9 | if (s.length === 0) return true; 10 | 11 | s = s.toLowerCase(); 12 | let i = 0, j = s.length - 1; 13 | while (i < j) { 14 | if ((s[i] < 'a' || s[i] > 'z') && (s[i] < '0' || s[i] > '9')) { 15 | i++; 16 | continue; 17 | } 18 | if ((s[j] < 'a' || s[j] > 'z') && (s[j] < '0' || s[j] > '9')) { 19 | j--; 20 | continue; 21 | } 22 | if (s[i] !== s[j]) { 23 | return false; 24 | } 25 | i++; 26 | j--; 27 | } 28 | 29 | return true; 30 | }; -------------------------------------------------------------------------------- /101-200/167-two-sum-ii.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ 4 | blog for this code :- https://rishabh1403.com/leetcode-solution-of-two-sum-ii-in-javascript 5 | youtube video :- https://www.youtube.com/watch?v=MjxN8HIzIRc 6 | */ 7 | 8 | 9 | var twoSum = function (numbers, target) { 10 | let i = 0; 11 | let j = numbers.length - 1; 12 | while (i !== j) { 13 | if (numbers[i] + numbers[j] > target) { 14 | j--; 15 | } else if (numbers[i] + numbers[j] < target) { 16 | i++; 17 | } else { 18 | return [i + 1, j + 1]; 19 | } 20 | } 21 | }; -------------------------------------------------------------------------------- /101-200/169-majority-element.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/majority-element/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-majority-element 5 | youtube video :- https://youtu.be/p0vvs4Gq8qY 6 | */ 7 | 8 | 9 | // sort and find middle 10 | var majorityElement = function (nums) { 11 | nums.sort((a, b) => a - b); 12 | 13 | const l = nums.length; 14 | 15 | if (l % 2 === 0) { 16 | return nums[l / 2] 17 | } else { 18 | return nums[(l - 1) / 2] 19 | } 20 | }; 21 | 22 | // Boyer–Moore majority vote algorithm 23 | // https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm 24 | var majorityElement = function (nums) { 25 | let maj = 0, count = 1; 26 | 27 | for (let i = 1; i < nums.length; i++) { 28 | if (nums[i] === nums[maj]) { 29 | count++ 30 | } else { 31 | count--; 32 | } 33 | 34 | if (count === 0) { 35 | maj = i; 36 | count = 1; 37 | } 38 | } 39 | return nums[maj] 40 | }; -------------------------------------------------------------------------------- /1101-1200/1108-defang-ip-address.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/defanging-an-ip-address/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-defang-ip-address 5 | youtube video :- https://youtu.be/s_CepLCQHNY 6 | */ 7 | 8 | /* 9 | Array Methods 10 | */ 11 | var defangIPaddr = function (address) { 12 | return address.split(".").join("[.]"); 13 | }; 14 | 15 | /* 16 | Regex 17 | */ 18 | 19 | var defangIPaddr = function (address) { 20 | return address.replace(/\./g, "[.]"); 21 | }; -------------------------------------------------------------------------------- /1101-1200/1185-day-f-week.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/day-of-the-week/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-day-of-week 5 | youtube video :- https://youtu.be/LiJ9H7I6AU0 6 | */ 7 | 8 | var dayOfTheWeek = function (day, month, year) { 9 | const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] 10 | 11 | return days[(new Date(year, month - 1, day)).getDay()] 12 | }; -------------------------------------------------------------------------------- /1201-1300/1252-cells-with-odd-values.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-cells-with-odd-values-in-a-matrix 5 | youtube video :- https://youtu.be/PfIdfEH2qMY 6 | */ 7 | 8 | var oddCells = function (n, m, indices) { 9 | const row = new Array(n).fill(0) 10 | const col = new Array(m).fill(0) 11 | 12 | for (let i = 0; i < indices.length; i++) { 13 | row[indices[i][0]]++; 14 | col[indices[i][1]]++; 15 | } 16 | 17 | let count = 0; 18 | 19 | for (let i = 0; i < n; i++) { 20 | for (let j = 0; j < m; j++) { 21 | if ((row[i] + col[j]) % 2 !== 0) { 22 | count++; 23 | } 24 | } 25 | } 26 | 27 | return count; 28 | }; -------------------------------------------------------------------------------- /1201-1300/1281-subtract-product-sum-of-digits.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-subtract-product-sum-of-digits-of-number 5 | youtube video :- https://youtu.be/BL6VoKQqlmM 6 | */ 7 | 8 | var subtractProductAndSum = function (n) { 9 | let product = 1, sum = 0; 10 | 11 | while (n > 0) { 12 | const digit = n % 10; 13 | n = parseInt(n / 10); 14 | 15 | product = product * digit; 16 | sum += digit 17 | } 18 | 19 | return product - sum 20 | }; -------------------------------------------------------------------------------- /1201-1300/1295-find-numbers-with-even-number-of-digits.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/find-numbers-with-even-number-of-digits/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-find-numbers-with-even-number-of-digits 5 | youtube video :- https://youtu.be/p9LaMHYY1R0 6 | */ 7 | 8 | 9 | var findNumbers = function (nums) { 10 | let count = 0; 11 | for (let num of nums) { 12 | let digit = 0; 13 | 14 | while (num > 0) { 15 | digit++; 16 | num = parseInt(num / 10); 17 | } 18 | 19 | if (digit % 2 === 0) count++; 20 | } 21 | 22 | return count; 23 | }; -------------------------------------------------------------------------------- /1301-1400/1313-decompress-run-length-encoded-list.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/decompress-run-length-encoded-list/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-decompress-run-length-encoded-list 5 | youtube video :- https://youtu.be/Ds5zZNOk89U 6 | */ 7 | 8 | var decompressRLElist = function (nums) { 9 | const res = []; 10 | 11 | for (let i = 0; i < nums.length; i += 2) { 12 | for (let j = 0; j < nums[i]; j++) { 13 | res.push(nums[i + 1]) 14 | } 15 | } 16 | 17 | return res; 18 | }; -------------------------------------------------------------------------------- /1301-1400/1342-reduce-numer-to-zero.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-number-of-steps-to-reduce-a-number-to-zero 5 | youtube video :- https://www.youtube.com/watch?v=sQYhrMf1VMc 6 | */ 7 | 8 | var numberOfSteps = function (num) { 9 | let counter = 0; 10 | while (num > 0) { 11 | if (num % 2 === 0) { 12 | num = num / 2; 13 | } else { 14 | num = num - 1; 15 | } 16 | counter++; 17 | } 18 | return counter; 19 | }; -------------------------------------------------------------------------------- /1301-1400/1365-how-many-numbers-smaller-than-current-number.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-how-many-numbers-smaller-than-current-number 5 | youtube video :- https://youtu.be/a2RWy9kqOhs 6 | */ 7 | 8 | 9 | var smallerNumbersThanCurrent = function (nums) { 10 | const sorted = [...nums].sort((a, b) => a - b); 11 | 12 | return nums.map(num => sorted.indexOf(num)); 13 | }; -------------------------------------------------------------------------------- /1301-1400/1389-create-target-array-in-the-given-order.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/create-target-array-in-the-given-order/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/create-target-array-in-the-given-order/ 5 | youtube video :- https://youtu.be/vZ6VpUJk7CU 6 | */ 7 | 8 | var createTargetArray = function(nums, index) { 9 | 10 | return index.reduce((acc,el,idx) => { 11 | return [...acc.slice(0,el), nums[idx], ...acc.slice(el)] 12 | },[]) 13 | }; -------------------------------------------------------------------------------- /201-300/205-isomorphic-strings.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/isomorphic-strings/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-isomorphic-strings 5 | youtube video :- https://youtu.be/h0O_iPBhxTs 6 | */ 7 | 8 | var isIsomorphic = function (s, t) { 9 | if (s.length !== t.length) return false; 10 | 11 | const mapa = new Map(); 12 | const mapb = new Map(); 13 | 14 | for (let i = 0; i < s.length; i++) { 15 | if (mapa.has(s[i])) { 16 | if (mapa.get(s[i]) !== t[i]) { 17 | return false; 18 | } 19 | } else { 20 | mapa.set(s[i], t[i]) 21 | } 22 | 23 | if (mapb.has(t[i])) { 24 | if (mapb.get(t[i]) !== s[i]) { 25 | return false; 26 | } 27 | } else { 28 | mapb.set(t[i], s[i]) 29 | } 30 | } 31 | 32 | return true 33 | 34 | }; -------------------------------------------------------------------------------- /201-300/217-contains-duplicate.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/contains-duplicate/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-contains-duplicate 5 | youtube video :- https://youtu.be/cuR5uyV8snc 6 | */ 7 | 8 | 9 | var containsDuplicate = function (nums) { 10 | const set = new Set(nums); 11 | 12 | return set.size !== nums.length 13 | }; -------------------------------------------------------------------------------- /201-300/219-contains-duplicate-ii.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/contains-duplicate-ii/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-contains-duplicate-ii 5 | youtube video :- https://youtu.be/O4MF2wBOrTM 6 | */ 7 | 8 | 9 | var containsNearbyDuplicate = function (nums, k) { 10 | const map = new Map(); 11 | 12 | for (let i = 0; i < nums.length; i++) { 13 | if (map.has(nums[i])) { 14 | const j = map.get(nums[i]); 15 | 16 | if (Math.abs(i - j) <= k) { 17 | return true; 18 | } 19 | } 20 | 21 | map.set(nums[i], i); 22 | } 23 | 24 | return false; 25 | }; -------------------------------------------------------------------------------- /201-300/242-valid-anagram.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/valid-anagram/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-valid-anagram 5 | youtube video :- https://youtu.be/7z25qqUCOUE 6 | */ 7 | 8 | var isAnagram = function (s, t) { 9 | const ans = new Array(26).fill(0); 10 | 11 | for (let i = 0; i < s.length; i++) { 12 | ans[s.charCodeAt(i) - 97]++; 13 | } 14 | 15 | for (let i = 0; i < t.length; i++) { 16 | ans[t.charCodeAt(i) - 97]--; 17 | } 18 | 19 | for (let i = 0; i < 26; i++) { 20 | if (ans[i] !== 0) 21 | return false; 22 | } 23 | 24 | return true; 25 | }; -------------------------------------------------------------------------------- /201-300/268-missing-number.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/missing-number/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-missing-number 5 | youtube video :- https://youtu.be/I6AUMvi13fc 6 | */ 7 | 8 | 9 | var missingNumber = function (nums) { 10 | const length = nums.length; 11 | let sum = ((length + 1) * length) / 2; 12 | 13 | for (let i = 0; i < length; i++) { 14 | sum = sum - nums[i]; 15 | } 16 | 17 | return sum; 18 | }; -------------------------------------------------------------------------------- /301-400/344-reverse-string.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/reverse-string/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-reverse-string 5 | youtube video :- https://youtu.be/8j24rPjGBwU 6 | */ 7 | 8 | 9 | var reverseString = function (s) { 10 | let left = 0, right = s.length - 1; 11 | 12 | while (left < right) { 13 | const temp = s[left]; 14 | s[left] = s[right]; 15 | s[right] = temp; 16 | 17 | left++; 18 | right--; 19 | } 20 | }; -------------------------------------------------------------------------------- /301-400/345-reverse-vowels-of-a-string.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/reverse-vowels-of-a-string/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-reverse-vowels-of-a-string 5 | youtube video :- https://youtu.be/5g6iV76aR-E 6 | */ 7 | 8 | var reverseVowels = function (s) { 9 | const arr = s.split(""); 10 | 11 | let left = 0, right = arr.length - 1; 12 | 13 | const vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'] 14 | 15 | while (left < right) { 16 | if (vowels.indexOf(arr[left]) === -1) { 17 | left++; 18 | continue; 19 | } 20 | if (vowels.indexOf(arr[right]) === -1) { 21 | right--; 22 | continue; 23 | } 24 | 25 | const temp = arr[left]; 26 | arr[left] = arr[right]; 27 | arr[right] = temp; 28 | 29 | left++; 30 | right--; 31 | } 32 | 33 | return arr.join("") 34 | }; -------------------------------------------------------------------------------- /301-400/349-intersection-of-two-arrays.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/intersection-of-two-arrays/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-intersection-of-two-arrays 5 | youtube video :- https://youtu.be/3OBr0wzEtWE 6 | */ 7 | 8 | var intersection = function (nums1, nums2) { 9 | const set1 = new Set(nums1); 10 | const set2 = new Set(nums2); 11 | 12 | const arr = []; 13 | 14 | for (let val of set1) { 15 | if (set2.has(val)) { 16 | arr.push(val) 17 | } 18 | } 19 | 20 | return arr; 21 | }; -------------------------------------------------------------------------------- /301-400/374-guess-number-higher-or-lower.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/guess-number-higher-or-lower/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-guess-number-higher-or-lower 5 | youtube video :- https://youtu.be/h0uL59Z9Hoc 6 | */ 7 | 8 | var guessNumber = function (n) { 9 | 10 | if (guess(n) === 0) return n 11 | 12 | let low = 1, high = n; 13 | while (n > 0) { 14 | const pick = (parseInt(high + low) / 2); 15 | const res = guess(pick); 16 | 17 | if (res === 0) { 18 | return pick 19 | } 20 | if (res === -1) { 21 | high = pick; 22 | } 23 | if (res === 1) { 24 | low = pick; 25 | } 26 | } 27 | }; -------------------------------------------------------------------------------- /301-400/383-ransom-note.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/ransom-note/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-ransom-note 5 | youtube video :- https://youtu.be/PkxRhIsvvf8 6 | */ 7 | 8 | var canConstruct = function (ransomNote, magazine) { 9 | const map = new Map(); 10 | 11 | for (let i = 0; i < magazine.length; i++) { 12 | if (map.has(magazine[i])) { 13 | map.set(magazine[i], map.get(magazine[i]) + 1) 14 | } else { 15 | map.set(magazine[i], 1) 16 | } 17 | } 18 | 19 | for (let i = 0; i < ransomNote.length; i++) { 20 | if (!map.has(ransomNote[i]) || map.get(ransomNote[i]) === 0) { 21 | return false; 22 | } 23 | map.set(ransomNote[i], map.get(ransomNote[i]) - 1) 24 | } 25 | 26 | return true; 27 | }; -------------------------------------------------------------------------------- /301-400/387-first-unique-character-in-a-string.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/first-unique-character-in-a-string/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/05/first-unique-character-in-a-string/ 5 | youtube video :- https://youtu.be/rxVNTwf_zfg 6 | */ 7 | 8 | var firstUniqChar = function (s) { 9 | const map = new Map(); 10 | 11 | for (let i = 0; i < s.length; i++) { 12 | if (map.has(s[i])) { 13 | map.set(s[i], -1) 14 | } else { 15 | map.set(s[i], i) 16 | } 17 | } 18 | for (let [key, value] of map) { 19 | if (value !== -1) { 20 | return value; 21 | } 22 | } 23 | 24 | return -1; 25 | }; -------------------------------------------------------------------------------- /501-600/509-fibonacci-number.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/fibonacci-number/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-fibonacci-number 5 | youtube video :- https://youtu.be/iyyhQfO_KKY 6 | */ 7 | 8 | 9 | // Recursive solution 10 | var fib = function (N) { 11 | if (N === 0 || N === 1) return N; 12 | 13 | return fib(N - 1) + fib(N - 2); 14 | 15 | }; 16 | 17 | // Iterative solution 18 | var fib = function (N) { 19 | if (N === 0 || N === 1) return N; 20 | 21 | let first = 0, second = 1; 22 | let sum = first + second; 23 | 24 | for (let i = 2; i < N; i++) { 25 | first = second; 26 | second = sum; 27 | 28 | sum = first + second; 29 | } 30 | 31 | return sum 32 | }; -------------------------------------------------------------------------------- /701-800/709-to-lower-case.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/to-lower-case/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-to-lower-case 5 | youtube video :- https://youtu.be/jFi7-YgIXJQ 6 | */ 7 | 8 | 9 | const isUpperCase = char => { 10 | let ascii = char.charCodeAt(0); 11 | 12 | if (ascii >= 65 && ascii <= 90) { 13 | return true; 14 | } 15 | 16 | return false 17 | } 18 | 19 | const toLower = char => { 20 | let ascii = char.charCodeAt(0); 21 | 22 | ascii = String.fromCharCode(ascii + 32); 23 | 24 | return ascii 25 | } 26 | 27 | var toLowerCase = function (str) { 28 | return str.split("").map(s => isUpperCase(s) ? toLower(s) : s).join(""); 29 | }; -------------------------------------------------------------------------------- /701-800/771-jewels-and-stones.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/jewels-and-stones/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-jewels-and-stones 5 | youtube video :- https://youtu.be/cNVJZF5UT1w 6 | */ 7 | 8 | var numJewelsInStones = function (J, S) { 9 | const set = new Set(J.split("")); 10 | let count = 0; 11 | 12 | for (let i = 0; i < S.length; i++) { 13 | if (set.has(S[i])) { 14 | count++; 15 | } 16 | } 17 | 18 | return count; 19 | }; -------------------------------------------------------------------------------- /801-900/867-transpose-matrix.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/transpose-matrix/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-transpose-matrix 5 | youtube video :- https://youtu.be/cMnPxDJlFIc 6 | */ 7 | 8 | var transpose = function (A) { 9 | 10 | const result = []; 11 | 12 | for (let i = 0; i < A[0].length; i++) { 13 | const col = [] 14 | for (let j = 0; j < A.length; j++) { 15 | col.push(A[j][i]); 16 | } 17 | result.push(col) 18 | } 19 | 20 | return result 21 | }; -------------------------------------------------------------------------------- /901-1000/929-unique-email-address.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author :- Rishabh Jain 3 | Solution for :- https://leetcode.com/problems/unique-email-addresses/ 4 | blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-unique-email-address 5 | youtube video :- https://youtu.be/X93pmKET_FY 6 | */ 7 | 8 | var numUniqueEmails = function (emails) { 9 | const set = new Set(); 10 | 11 | for (const email of emails) { 12 | const arr = email.split("@"); 13 | 14 | // ignore everything after first occurence of + 15 | arr[0] = (arr[0].split("+"))[0]; 16 | 17 | // replace all dots with nothing i.e. empty string 18 | arr[0] = arr[0].replace(/\./g, ""); 19 | 20 | // add final email ( processed ) to set 21 | set.add(arr.join("@")); 22 | } 23 | 24 | return set.size; 25 | }; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Rishabh Jain 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Leetcode Solutions in JavaScript 2 | 3 | [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/rishabh1403/leetcode-javascript-solutions/graphs/commit-activity) [![made-with-js](https://img.shields.io/badge/Made%20with-JS-yellowgreen)](https://nodejs.org/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php) [![HitCount](http://hits.dwyl.io/rishabh1403/leetcode-javascript-solutions.svg)](http://hits.dwyl.io/rishabh1403/leetcode-javascript-solutions) 4 | 5 | Solutions of all the questions from Leetcode in JavaScript. 6 | 7 | ***This is an on-going series where I post solutions of questions on JavaScript with explanations on my [blog](https://rishabh1403.com). Use the links below for the question statement, complete source code, blog post and [youtube video](https://youtube.com/rishabh1403).*** 8 | 9 | # Questions 10 | 11 | - 1.Two Sum - [Question](https://leetcode.com/problems/two-sum/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/1-two-sum.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/11/leetcode-solution-of-two-sum-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=qqC9m93ofwI) 12 | 13 | - 7.Reverse Integer - [Question](https://leetcode.com/problems/reverse-integer/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/7-reverse-integer.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/11/leetcode-solution-of-reverse-integer-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=cIBwTqjh6VQ) 14 | 15 | - 9.Palindrome Number - [Question](https://leetcode.com/problems/palindrome-number/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/9-palindrome-number.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/12/leetcode-solution-of-palindrome-number-in-javascript) | [Youtube Video](https://youtu.be/7lCkkX3UAvU) 16 | 17 | - 20.Valid Parentheses - [Question](https://leetcode.com/problems/valid-parentheses/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/20-valid-parentheses.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/09/leetcode-solution-of-valid-parentheses-in-javascript) | [Youtube Video](https://youtu.be/OuRH74PiPas) 18 | 19 | - 28.Implement strStr() - [Question](https://leetcode.com/problems/implement-strstr/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/28-implement-strstr.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-implement-strstr) | [Youtube Video](https://youtu.be/pKa_2pLb3Rw) 20 | 21 | - 35.Search Insert Position - [Question](https://leetcode.com/problems/search-insert-position/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/35-search-insert-position.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-search-insert-position) | [Youtube Video](https://youtu.be/l2XPvyTlC6c) 22 | 23 | - 58.Length of Last Word - [Question](https://leetcode.com/problems/length-of-last-word/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/58-length-of-last-word.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-length-of-last-word) | [Youtube Video](https://youtu.be/2PQ4vtnLfnw) 24 | 25 | - 125.Valid Palindrome - [Question](https://leetcode.com/problems/valid-palindrome/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/125-valid-palindrome.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-valid-palindrome) | [Youtube Video](https://youtu.be/zqQRjBbwRew) 26 | 27 | - 167.Two Sum-II - [Question](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/167-two-sum-ii.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/12/leetcode-solution-of-two-sum-ii-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=MjxN8HIzIRc) 28 | 29 | - 169.Majority Element - [Question](https://leetcode.com/problems/majority-element/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/169-majority-element.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-majority-element) | [Youtube Video](https://youtu.be/p0vvs4Gq8qY) 30 | 31 | - 205.Isomorphic Strings - [Question](https://leetcode.com/problems/isomorphic-strings/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/201-300/205-isomorphic-strings.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-isomorphic-strings) | [Youtube Video](https://youtu.be/h0O_iPBhxTs) 32 | 33 | - 217.Contains Duplicate - [Question](https://leetcode.com/problems/contains-duplicate/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/201-300/217-contains-duplicate.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-contains-duplicate) | [Youtube Video](https://youtu.be/cuR5uyV8snc) 34 | 35 | - 219.Contains Duplicate II - [Question](https://leetcode.com/problems/contains-duplicate-ii/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/201-300/219-contains-duplicate-ii.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-contains-duplicate-ii) | [Youtube Video](https://youtu.be/O4MF2wBOrTM) 36 | 37 | - 242.Valid Anagram - [Question](https://leetcode.com/problems/valid-anagram/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/201-300/242-valid-anagram.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-valid-anagram) | [Youtube Video](https://youtu.be/7z25qqUCOUE) 38 | 39 | - 268.Missing Number - [Question](https://leetcode.com/problems/missing-number/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/201-300/268-missing-number.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-missing-number) | [Youtube Video](https://youtu.be/I6AUMvi13fc) 40 | 41 | - 344.Reverse String - [Question](https://leetcode.com/problems/reverse-string/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/301-400/344-reverse-string.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-reverse-string) | [Youtube Video](https://youtu.be/8j24rPjGBwU) 42 | 43 | - 345.Reverse Vowels of a String - [Question](https://leetcode.com/problems/reverse-vowels-of-a-string/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/301-400/345-reverse-vowels-of-a-string.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-reverse-vowels-of-a-string) | [Youtube Video](https://youtu.be/5g6iV76aR-E) 44 | 45 | - 349.Intersection of Two Arrays - [Question](https://leetcode.com/problems/intersection-of-two-arrays/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/301-400/349-intersection-of-two-arrays.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-intersection-of-two-arrays) | [Youtube Video](https://youtu.be/3OBr0wzEtWE) 46 | 47 | - 374.Guess Number Higher or Lower - [Question](https://leetcode.com/problems/guess-number-higher-or-lower/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/301-400/374-guess-number-higher-or-lower.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-guess-number-higher-or-lower) | [Youtube Video](https://youtu.be/h0uL59Z9Hoc) 48 | 49 | - 383.Ransom Note - [Question](https://leetcode.com/problems/ransom-note/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/301-400/383-ransom-note.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/leetcode-ransom-note) | [Youtube Video](https://youtu.be/PkxRhIsvvf8) 50 | 51 | - 387.First Unique Character in a String - [Question](https://leetcode.com/problems/first-unique-character-in-a-string/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/301-400/387-first-unique-character-in-a-string.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/first-unique-character-in-a-string/) | [Youtube Video](https://youtu.be/rxVNTwf_zfg) 52 | 53 | - 509.Fibonacci Number - [Question](https://leetcode.com/problems/fibonacci-number/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/501-600/509-fibonacci-number.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-fibonacci-number) | [Youtube Video](https://youtu.be/iyyhQfO_KKY) 54 | 55 | - 709.To Lower Case - [Question](https://leetcode.com/problems/to-lower-case/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/701-800/709-to-lower-case.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-to-lower-case) | [Youtube Video](https://youtu.be/jFi7-YgIXJQ) 56 | 57 | - 771.Jewels and Stones - [Question](https://leetcode.com/problems/jewels-and-stones/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/701-800/771-jewels-and-stones.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-jewels-and-stones) | [Youtube Video](https://youtu.be/cNVJZF5UT1w) 58 | 59 | - 867.Transpose Matrix - [Question](https://leetcode.com/problems/transpose-matrix/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/801-900/867-transpose-matrix.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-transpose-matrix) | [Youtube Video](https://youtu.be/cMnPxDJlFIc) 60 | 61 | - 929.Unique Email Addresses - [Question](https://leetcode.com/problems/unique-email-addresses/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/901-1000/929-unique-email-address.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-unique-email-address) | [Youtube Video](https://youtu.be/X93pmKET_FY) 62 | 63 | - 1108.Defanging an IP Address - [Question](https://leetcode.com/problems/defanging-an-ip-address/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1101-1200/1108-defang-ip-address.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-defang-ip-address) | [Youtube Video](https://youtu.be/s_CepLCQHNY) 64 | 65 | - 1185.Day of the Week - [Question](https://leetcode.com/problems/day-of-the-week/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1101-1200/1185-day-f-week.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-day-of-week) | [Youtube Video](https://youtu.be/LiJ9H7I6AU0) 66 | 67 | - 1252.Cells with Odd Values in a Matrix - [Question](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1201-1300/1252-cells-with-odd-values.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-cells-with-odd-values-in-a-matrix) | [Youtube Video](https://youtu.be/PfIdfEH2qMY) 68 | 69 | - 1281.Subtract the Product and Sum of Digits of an Integer - [Question](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1201-1300/1281-subtract-product-sum-of-digits.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-subtract-product-sum-of-digits-of-number) | [Youtube Video](https://youtu.be/BL6VoKQqlmM) 70 | 71 | - 1295.Find Numbers with Even Number of Digits - [Question](https://leetcode.com/problems/find-numbers-with-even-number-of-digits//) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1201-1300/1295-find-numbers-with-even-number-of-digits.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-find-numbers-with-even-number-of-digits) | [Youtube Video](https://youtu.be/p9LaMHYY1R0) 72 | 73 | - 1313.Decompress Run-Length Encoded List - [Question](https://leetcode.com/problems/decompress-run-length-encoded-list/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1301-1400/1313-decompress-run-length-encoded-list.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-decompress-run-length-encoded-list) | [Youtube Video](https://youtu.be/Ds5zZNOk89U) 74 | 75 | - 1342.Number of Steps to Reduce a Number to Zero - [Question](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1301-1400/1342-reduce-numer-to-zero.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-number-of-steps-to-reduce-a-number-to-zero) | [Youtube Video](https://www.youtube.com/watch?v=sQYhrMf1VMc) 76 | 77 | - 1365.How Many Numbers Are Smaller Than the Current Number - [Question](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1301-1400/1365-how-many-numbers-smaller-than-current-number.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-how-many-numbers-smaller-than-current-number) | [Youtube Video](https://youtu.be/a2RWy9kqOhs) 78 | 79 | - 1389.Create Target Array in the Given Order - [Question](https://leetcode.com/problems/create-target-array-in-the-given-order/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1301-1400/1389-create-target-array-in-the-given-order.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/05/create-target-array-in-the-given-order/) | [Youtube Video](https://youtu.be/vZ6VpUJk7CU) 80 | --------------------------------------------------------------------------------