Skip to content

gusaiani/leetcode-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

126 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests Lint

LeetCode in JavaScript

Solutions to LeetCode problems in JavaScript, each with a test suite.

Solved Problems

# Problem Difficulty Approach Time Space
1 Two Sum Easy Hash map O(n) O(n)
3 Longest Substring Without Repeating Characters Medium Sliding window O(n) O(min(n, m))
15 3Sum Medium Sort + two pointers O(n²) O(n)
23 Merge k Sorted Lists Hard Divide and conquer O(n log k) O(1)
4 Median of Two Sorted Arrays Hard Binary search O(log min(m, n)) O(1)
6 Zigzag Conversion Medium Row simulation O(n) O(n)
9 Palindrome Number Easy Two pointers on string O(n) O(n)
12 Integer to Roman Medium Greedy (value table) O(1) O(1)
13 Roman to Integer Easy Linear scan O(n) O(1)
14 Longest Common Prefix Easy Vertical scan O(n × m) O(m)
20 Valid Parentheses Easy Recursive matching O(n²) O(n)
21 Merge Two Sorted Lists Easy Iterative merge O(n + m) O(n + m)
26 Remove Duplicates from Sorted Array Easy Reduce O(n) O(1)
28 Find the Index of the First Occurrence in a String Easy KMP algorithm O(n + m) O(m)
35 Search Insert Position Easy Linear scan O(n) O(1)
38 Count and Say Medium Recursion O(2ⁿ) O(2ⁿ)
39 Combination Sum Medium Backtracking O(n^(t/m)) O(t/m)
51 N-Queens Hard Backtracking O(n!) O(n²)
53 Maximum Subarray Medium Kadane's algorithm O(n) O(1)
55 Jump Game Medium Greedy (max reach) O(n) O(1)
56 Merge Intervals Medium Sort + linear merge O(n log n) O(n)
58 Length of Last Word Easy Reverse scan O(n) O(n)
66 Plus One Easy Right-to-left carry O(n) O(1)
70 Climbing Stairs Easy Dynamic programming O(n) O(1)
83 Remove Duplicates from Sorted List Easy Iterative skip O(n) O(1)
88 Merge Sorted Array Easy Two pointers (reverse) O(m + n) O(1)
102 Binary Tree Level Order Traversal Medium BFS with queue O(n) O(n)
104 Maximum Depth of Binary Tree Easy DFS recursion O(n) O(h)
112 Path Sum Easy DFS recursion O(n) O(h)
121 Best Time to Buy and Sell Stock Easy Greedy (min tracking) O(n) O(1)
125 Valid Palindrome Easy Two pointers O(n) O(1)
136 Single Number Easy Set (add/delete) O(n) O(n)
141 Linked List Cycle Easy Hash set (references) O(n) O(n)
146 LRU Cache Medium Doubly linked list + map O(1) O(n)
153 Find Minimum in Rotated Sorted Array Medium Linear scan O(n) O(1)
155 Min Stack Medium Two stacks O(1) O(n)
169 Majority Element Easy Hash map O(n) O(n)
198 House Robber Easy DP (two variables) O(n) O(1)
200 Number of Islands Medium DFS recursion (sink) O(m × n) O(m × n)
202 Happy Number Easy Recursion (4-cycle) O(log n) O(log n)
208 Implement Trie (Prefix Tree) Medium Trie (prefix tree) O(m) O(m)
206 Reverse Linked List Easy Iterative reversal O(n) O(1)
226 Invert Binary Tree Easy DFS recursion O(n) O(h)
207 Course Schedule Medium Topological sort (BFS) O(V + E) O(V + E)
215 Kth Largest Element in an Array Medium Quickselect O(n) O(1)
217 Contains Duplicate Easy Hash map O(n) O(n)
238 Product of Array Except Self Medium Prefix/suffix product O(n) O(1)
242 Valid Anagram Easy Hash map O(n) O(n)
268 Missing Number Easy Gauss sum formula O(n) O(1)
283 Move Zeroes Easy Two pointers O(n) O(1)
322 Coin Change Medium Dynamic programming O(n × amount) O(amount)
347 Top K Frequent Elements Medium Hash map + sort O(n log n) O(n)
392 Is Subsequence Easy Two pointers O(n) O(n)
409 Longest Palindrome Easy Hash map (freq count) O(n) O(n)
448 Find All Numbers Disappeared in an Array Easy Set complement O(n) O(n)
461 Hamming Distance Easy XOR + bit count O(1) O(1)
543 Diameter of Binary Tree Easy DFS recursion O(n) O(h)
560 Subarray Sum Equals K Medium Prefix sum + hash map O(n) O(n)
572 Subtree of Another Tree Easy DFS recursion O(m × n) O(h)
733 Flood Fill Easy DFS recursion (matrix) O(m × n) O(m × n)
1235 Maximum Profit in Job Scheduling Hard DP + binary search O(n log n) O(n)
3379 Transformed Array Easy Modular arithmetic O(n) O(n)

Setup

bun install

Scripts

Command Description
bun test Run all tests
bun test --watch Run tests in watch mode
bun run lint Check for linting errors
bun run lint:fix Auto-fix linting errors
bun run format Format all files with Biome
bun run format:check Check formatting without modifying

Code Quality

  • Testing — Every solution has a dedicated test file (Jest-compatible, run via Bun)
  • Linting & FormattingBiome for linting and consistent style
  • CI — GitHub Actions run tests, linting, and format checks on every PR
  • Pre-push hookHusky blocks pushes that fail tests, linting, or formatting

About

In this repo I solve Leetcode’s challenges using JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors