Skip to content

chenxiaoyao6228/leetcode-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode-js

Leetcode solutions in Javascript. All JavaScript codes are written in ECMAScript 6 standard. Some questions may include more than one solution.

Debugging

For local debugging purposes, some questions also provide test cases with Jest, If you are using Vscode, I suggest you install Vitest and Vitest runner and go to the corresponding test case. You can also call the function directly in the question file and hit the Run and Debug Button on the sidebar and select Debug currentFile option to start debugging.

Table of solutions

Total Submit: 159/300(Goal)

ID Title Difficulty Solutions Test Case Explanation
1 Two Sum(en, cn) Easy Javascript test
3 Longest Substring Without Repeating Characters(en, cn) Medium Javascript test
4 Median of Two Sorted Arrays(en, cn) Hard Javascript test
5 Longest Palindromic Substring(en, cn) Medium Javascript test
7 Reverse Integer(en, cn) Medium Javascript test
11 Container With Most Water(en, cn) Medium Javascript test
15 3Sum(en, cn) Medium Javascript test
16 3Sum Closest(en, cn) Medium Javascript test
17 Letter Combinations of a Phone Number(en, cn) Medium Javascript test
18 4Sum(en, cn) Medium Javascript test
19 Remove Nth Node From End of List(en, cn) Medium Javascript test
20 Valid Parentheses(en, cn) Easy Javascript test
21 Merge Two Sorted Lists(en, cn) Easy Javascript test
23 Merge k Sorted Lists(en, cn) Hard Javascript
24 Swap Nodes in Pairs(en, cn) Medium Javascript test
25 Reverse Nodes in k-Group(en, cn) Hard Javascript test
26 Remove Duplicates from Sorted Array(en, cn) Easy Javascript test
27 Remove Element(en, cn) Easy Javascript test
34 Find First and Last Position of Element in Sorted Array(en, cn) Medium Javascript
35 Search Insert Position(en, cn) Easy Javascript
39 Combination Sum(en, cn) Medium Javascript
40 Combination Sum II(en, cn) Medium Javascript
46 Permutations(en, cn) Medium Javascript
47 Permutations II(en, cn) Medium Javascript
51 N-Queens(en, cn) Hard Javascript
52 N-Queens II(en, cn) Hard Javascript test
64 Minimum Path Sum(en, cn) Medium Javascript test
72 Edit Distance(en, cn) Hard Javascript
75 Sort Colors(en, cn) Medium Javascript test
76 Minimum Window Substring(en, cn) Hard Javascript test
77 Combinations(en, cn) Medium Javascript test
78 Subsets(en, cn) Medium Javascript
79 Word Search(en, cn) Medium Javascript test
80 Remove Duplicates from Sorted Array II(en, cn) Medium Javascript test
83 Remove Duplicates from Sorted List(en, cn) Easy Javascript test
86 Partition List(en, cn) Medium Javascript test
88 Merge Sorted Array(en, cn) Easy Javascript test
90 Subsets II(en, cn) Medium Javascript
92 Reverse Linked List II(en, cn) Medium Javascript test
94 Binary Tree Inorder Traversal(en, cn) Easy Javascript test
95 Unique Binary Search Trees II(en, cn) Medium Javascript
96 Unique Binary Search Trees(en, cn) Medium Javascript
98 Validate Binary Search Tree(en, cn) Medium Javascript
100 Same Tree(en, cn) Easy Javascript
101 Symmetric Tree(en, cn) Easy Javascript
102 Binary Tree Level Order Traversal(en, cn) Medium Javascript
103 Binary Tree Zigzag Level Order Traversal(en, cn) Medium Javascript
104 Maximum Depth of Binary Tree(en, cn) Easy Javascript
105 Construct Binary Tree from Preorder and Inorder Traversal(en, cn) Medium Javascript test
106 Construct Binary Tree from Inorder and Postorder Traversal(en, cn) Medium Javascript test
107 Binary Tree Level Order Traversal II(en, cn) Medium Javascript
108 Convert Sorted Array to Binary Search Tree(en, cn) Easy Javascript
110 Balanced Binary Tree(en, cn) Easy Javascript
111 Minimum Depth of Binary Tree(en, cn) Easy Javascript
112 Path Sum(en, cn) Easy Javascript
113 Path Sum II(en, cn) Medium Javascript
114 Flatten Binary Tree to Linked List(en, cn) Medium Javascript test
116 Populating Next Right Pointers in Each Node(en, cn) Medium Javascript test
117 Populating Next Right Pointers in Each Node II(en, cn) Medium Javascript
124 Binary Tree Maximum Path Sum(en, cn) Hard Javascript
125 Valid Palindrome(en, cn) Easy Javascript test
129 Sum Root to Leaf Numbers(en, cn) Medium Javascript
141 Linked List Cycle(en, cn) Easy Javascript
144 Binary Tree Preorder Traversal(en, cn) Easy Javascript test
145 Binary Tree Postorder Traversal(en, cn) Easy Javascript test
146 LRU Cache(en, cn) Medium Javascript test
147 Insertion Sort List(en, cn) Medium Javascript test
149 Max Points on a Line(en, cn) Hard Javascript test
160 Intersection of Two Linked Lists(en, cn) Easy Javascript
167 Two Sum II - Input Array Is Sorted(en, cn) Medium Javascript test
173 Binary Search Tree Iterator(en, cn) Medium Javascript
200 Number of Islands(en, cn) Medium Javascript
202 Happy Number(en, cn) Easy Javascript test
205 Isomorphic Strings(en, cn) Easy Javascript test
206 Reverse Linked List(en, cn) Easy Javascript test
207 Course Schedule(en, cn) Medium Javascript test
209 Minimum Size Subarray Sum(en, cn) Medium Javascript test
210 Course Schedule II(en, cn) Medium Javascript test
216 Combination Sum III(en, cn) Medium Javascript test
219 Contains Duplicate II(en, cn) Easy Javascript test
220 Contains Duplicate III(en, cn) Hard Javascript test
222 Count Complete Tree Nodes(en, cn) Medium Javascript
226 Invert Binary Tree(en, cn) Easy Javascript test
230 Kth Smallest Element in a BST(en, cn) Medium Javascript test
234 Palindrome Linked List(en, cn) Easy Javascript test
235 Lowest Common Ancestor of a Binary Search Tree(en, cn) Medium Javascript
236 Lowest Common Ancestor of a Binary Tree(en, cn) Medium Javascript
239 Sliding Window Maximum(en, cn) Hard Javascript test
257 Binary Tree Paths(en, cn) Easy Javascript
283 Move Zeroes(en, cn) Easy Javascript test
290 Word Pattern(en, cn) Easy Javascript test
297 Serialize and Deserialize Binary Tree(en, cn) Hard Javascript
300 Longest Increasing Subsequence(en, cn) Medium Javascript test
303 Range Sum Query - Immutable(en, cn) Easy Javascript
316 Remove Duplicate Letters(en, cn) Medium Javascript test explanation
322 Coin Change(en, cn) Medium Javascript
344 Reverse String(en, cn) Easy Javascript test
345 Reverse Vowels of a String(en, cn) Easy Javascript test
349 Intersection of Two Arrays(en, cn) Easy Javascript test
350 Intersection of Two Arrays II(en, cn) Easy Javascript test
354 Russian Doll Envelopes(en, cn) Hard Javascript
380 Insert Delete GetRandom O(1)(en, cn) Medium Javascript test
416 Partition Equal Subset Sum(en, cn) Medium Javascript test
438 Find All Anagrams in a String(en, cn) Medium Javascript test
450 Delete Node in a BST(en, cn) Medium Javascript test
460 LFU Cache(en, cn) Hard Javascript test
496 Next Greater Element I(en, cn) Easy Javascript test explanation
501 Find Mode in Binary Search Tree(en, cn) Easy Javascript
503 Next Greater Element II(en, cn) Medium Javascript test
506 Relative Ranks(en, cn) Easy Javascript test
513 Find Bottom Left Tree Value(en, cn) Medium Javascript
515 Find Largest Value in Each Tree Row(en, cn) Medium Javascript
518 Coin Change II(en, cn) Medium Javascript test
530 Minimum Absolute Difference in BST(en, cn) Easy Javascript
538 Convert BST to Greater Tree(en, cn) Medium Javascript
543 Diameter of Binary Tree(en, cn) Easy Javascript
559 Maximum Depth of N-ary Tree(en, cn) Easy Javascript
563 Binary Tree Tilt(en, cn) Easy Javascript
567 Permutation in String(en, cn) Medium Javascript test
572 Subtree of Another Tree(en, cn) Easy Javascript
589 N-ary Tree Preorder Traversal(en, cn) Easy Javascript
590 N-ary Tree Postorder Traversal(en, cn) Easy Javascript
617 Merge Two Binary Trees(en, cn) Easy Javascript
643 Maximum Average Subarray I(en, cn) Easy Javascript test
652 Find Duplicate Subtrees(en, cn) Medium Javascript test
653 Two Sum IV - Input is a BST(en, cn) Easy Javascript
654 Maximum Binary Tree(en, cn) Medium Javascript test
662 Maximum Width of Binary Tree(en, cn) Medium Javascript
671 Second Minimum Node In a Binary Tree(en, cn) Easy Javascript
687 Longest Univalue Path(en, cn) Medium Javascript
700 Search in a Binary Search Tree(en, cn) Easy Javascript
701 Insert into a Binary Search Tree(en, cn) Medium Javascript test
704 Binary Search(en, cn) Easy Javascript
710 Random Pick with Blacklist(en, cn) Hard Javascript test
739 Daily Temperatures(en, cn) Medium Javascript test
752 Open the Lock(en, cn) Medium Javascript
773 Sliding Puzzle(en, cn) Hard Javascript
783 Minimum Distance Between BST Nodes(en, cn) Easy Javascript test
785 Is Graph Bipartite?(en, cn) Medium Javascript
797 All Paths From Source to Target(en, cn) Medium Javascript test
862 Shortest Subarray with Sum at Least K(en, cn) Hard Javascript test explanation
872 Leaf-Similar Trees(en, cn) Easy Javascript test
876 Middle of the Linked List(en, cn) Easy Javascript test
886 Possible Bipartition(en, cn) Medium Javascript
889 Construct Binary Tree from Preorder and Postorder Traversal(en, cn) Medium Javascript test
921 Minimum Add to Make Parentheses Valid(en, cn) Medium Javascript
931 Minimum Falling Path Sum(en, cn) Medium Javascript test
965 Univalued Binary Tree(en, cn) Easy Javascript test
988 Smallest String Starting From Leaf(en, cn) Medium Javascript
998 Maximum Binary Tree II(en, cn) Medium Javascript
1008 Construct Binary Search Tree from Preorder Traversal(en, cn) Medium Javascript
1038 Binary Search Tree to Greater Sum Tree(en, cn) Medium Javascript test
1094 Car Pooling(en, cn) Medium Javascript
1143 Longest Common Subsequence(en, cn) Medium Javascript
1373 Maximum Sum BST in Binary Tree(en, cn) Hard Javascript
1541 Minimum Insertions to Balance a Parentheses String(en, cn) Medium Javascript test
1695 Maximum Erasure Value(en, cn) Medium Javascript test