A curated collection of JavaScript problems grouped by topic, designed for SDE-2 level interviews.
Each problem is located in the problems/ folder with its own test case in tests/.
| # | Problem | File |
|---|---|---|
| 05 | Find Largest Number in Array | 05-find-largest-number-in-array.js |
| 06 | Remove Duplicates from Array | 06-remove-duplicates-from-array.js |
| 07 | Element Frequency in Array | 07-element-frequency-in-array.js |
| 10 | Flatten Nested Array | 10-flatten-nested-array.js |
| 11 | Rotate Array by K Steps | 11-rotate-array-by-k-steps.js |
| 15 | Move All Zeroes to End | 15-move-all-zeroes-to-end.js |
| 16 | Merge Two Sorted Arrays | 16-merge-two-sorted-arrays.js |
| 17 | All Pairs with Given Sum | 17-all-pairs-with-given-sum.js |
| 20 | Product of Array Except Self | 20-product-of-array-except-self.js |
| 51 | Find Intersection of Two Arrays | 51-find-intersection-of-two-arrays.js |
| 57 | Count Occurrences of Element | 57-count-occurrences-of-element.js |
| 61 | Majority Element | 61-majority-element.js |
| 71 | Find Duplicates in Array | 71-find-duplicates-in-array.js |
| 72 | Two Sum Problem | 72-two-sum-problem.js |
| 73 | Three Sum Problem | 73-three-sum-problem.js |
| 99 | Sort by Frequency | 99-sort-by-frequency.js |
| # | Problem | File |
|---|---|---|
| 40 | Promisify Callback | 40-promisify-callback.js |
| 41 | Promise.all Polyfill | 41-promise.all-polyfill.js |
| 42 | Retry Failed Fetch | 42-retry-failed-fetch.js |
| 43 | Chain Async Operations | 43-chain-async-operations.js |
| 44 | Timeout Wrapper for Promise | 44-timeout-wrapper-for-promise.js |
| 45 | Sequential vs Parallel Promises | 45-sequential-vs-parallel-promises.js |
| # | Problem | File |
|---|---|---|
| 28 | N-Queens Problem | 28-n-queens-problem.js |
| 29 | Sudoku Solver | 29-sudoku-solver.js |
| # | Problem | File |
|---|---|---|
| 55 | Find Peak Element | 55-find-peak-element.js |
| # | Problem | File |
|---|---|---|
| 23 | Count Set Bits | 23-count-set-bits.js |
| # | Problem | File |
|---|---|---|
| 74 | Count Islands in Matrix | 74-count-islands-in-matrix.js |
| # | Problem | File |
|---|---|---|
| 67 | Word Break Problem | 67-word-break-problem.js |
| 68 | Climb Stairs (Fibonacci) | 68-climb-stairs-fibonacci.js |
| 69 | Coin Change | 69-coin-change.js |
| 70 | Unique Paths in Grid | 70-unique-paths-in-grid.js |
| # | Problem | File |
|---|---|---|
| 32 | LRU Cache | 32-lru-cache.js |
| 46 | Event Emitter | 46-event-emitter.js |
| 47 | Rate Limiter | 47-rate-limiter.js |
| 48 | Autocomplete with Trie | 48-autocomplete-with-trie.js |
| 49 | Job Scheduler | 49-job-scheduler.js |
| 50 | In-memory Key-Value Store | 50-in-memory-key-value-store.js |
| 82 | Design Stack with Min | 82-design-stack-with-min.js |
| 83 | Browser History Navigation | 83-browser-history-navigation.js |
| 84 | LRU Cache with Doubly Linked List | 84-lru-cache-with-doubly-linked-list.js |
| # | Problem | File |
|---|---|---|
| 36 | Custom Map Polyfill | 36-custom-map-polyfill.js |
| 37 | Custom Reduce Polyfill | 37-custom-reduce-polyfill.js |
| 38 | Debounce Implementation | 38-debounce-implementation.js |
| 39 | Memoize Function | 39-memoize-function.js |
| 90 | Throttle Implementation | 90-throttle-implementation.js |
| 91 | Function Currying | 91-function-currying.js |
| 92 | Custom Bind Polyfill | 92-custom-bind-polyfill.js |
| 93 | Compose Function | 93-compose-function.js |
| # | Problem | File |
|---|---|---|
| 85 | Clone Graph | 85-clone-graph.js |
| 86 | Detect Cycle in Graph | 86-detect-cycle-in-graph.js |
| 87 | Topological Sort | 87-topological-sort.js |
| 88 | Dijkstra's Algorithm | 88-dijkstra's-algorithm.js |
| 89 | A* Pathfinding | 89-a*-pathfinding.js |
| # | Problem | File |
|---|---|---|
| 12 | Group Anagrams | 12-group-anagrams.js |
| # | Problem | File |
|---|---|---|
| 04 | FizzBuzz | 04-fizzbuzz.js |
| # | Problem | File |
|---|---|---|
| 33 | Frequency Counter using Map | 33-frequency-counter-using-map.js |
| # | Problem | File |
|---|---|---|
| 13 | Missing Number from 1 to N | 13-missing-number-from-1-to-n.js |
| 21 | Check Prime Number | 21-check-prime-number.js |
| 22 | GCD and LCM | 22-gcd-and-lcm.js |
| 24 | Armstrong Number | 24-armstrong-number.js |
| 96 | Generate Random Hex Color | 96-generate-random-hex-color.js |
| 97 | UUID Generator | 97-uuid-generator.js |
| 98 | Binary to Decimal Converter | 98-binary-to-decimal-converter.js |
| # | Problem | File |
|---|---|---|
| 58 | Spiral Order Matrix | 58-spiral-order-matrix.js |
| 59 | Transpose Matrix | 59-transpose-matrix.js |
| 66 | Set Matrix Zeroes | 66-set-matrix-zeroes.js |
| # | Problem | File |
|---|---|---|
| 31 | Deep Clone Object | 31-deep-clone-object.js |
| 34 | Group Objects by Key | 34-group-objects-by-key.js |
| 35 | Deep Equality Check | 35-deep-equality-check.js |
| 95 | Deep Freeze Object | 95-deep-freeze-object.js |
| # | Problem | File |
|---|---|---|
| 03 | Factorial of a Number | 03-factorial-of-a-number.js |
| 26 | All Permutations of String | 26-all-permutations-of-string.js |
| 27 | Tower of Hanoi | 27-tower-of-hanoi.js |
| 30 | Power Set | 30-power-set.js |
| # | Problem | File |
|---|---|---|
| 56 | Binary Search Implementation | 56-binary-search-implementation.js |
| 60 | Search in Rotated Sorted Array | 60-search-in-rotated-sorted-array.js |
| # | Problem | File |
|---|---|---|
| 18 | Longest Unique Substring | 18-longest-unique-substring.js |
| 65 | Minimum Window Substring | 65-minimum-window-substring.js |
| # | Problem | File |
|---|---|---|
| 52 | Check Balanced Parentheses | 52-check-balanced-parentheses.js |
| 53 | Evaluate Reverse Polish Notation | 53-evaluate-reverse-polish-notation.js |
| # | Problem | File |string/ |--:|---------|------| | 01 | Reverse a String | 01-reverse-a-string.js | | 02 | Check if a String is Palindrome | 02-check-if-a-string-is-palindrome.js | | 08 | Anagram Check | 08-anagram-check.js | | 09 | Capitalize First Letter | 09-capitalize-first-letter.js | | 14 | First Non-Repeating Character | 14-first-non-repeating-character.js | | 19 | Is Subsequence | 19-is-subsequence.js | | 25 | Roman to Integer | 25-roman-to-integer.js | | 54 | Longest Common Prefix | 54-longest-common-prefix.js | | 62 | Zigzag Conversion | 62-zigzag-conversion.js | | 63 | String Compression | 63-string-compression.js | | 64 | Longest Palindromic Substring | 64-longest-palindromic-substring.js | | 94 | Parse Query String | 94-parse-query-string.js | | 101| Reverse All Strings of a Sentence | 101-reverse-all-strings.js |
| # | Problem | File |
|---|---|---|
| 75 | Max Depth of Binary Tree | 75-max-depth-of-binary-tree.js |
| 76 | Level Order Traversal | 76-level-order-traversal.js |
| 77 | Binary Tree Inorder Traversal | 77-binary-tree-inorder-traversal.js |
| 78 | Lowest Common Ancestor | 78-lowest-common-ancestor.js |
| 79 | Validate Binary Search Tree | 79-validate-binary-search-tree.js |
| 80 | Invert Binary Tree | 80-invert-binary-tree.js |
| 81 | Serialize and Deserialize Tree | 81-serialize-and-deserialize-tree.js |
-
Install dependencies (for running tests):
npm install
-
Solve problems inside the
problems/folder. -
Add or review test cases in the
tests/folder. -
Run tests using:
npm test
Tests are powered by Jest.
Feel free to fork and submit PRs with solutions or improvements.