xxwudi508 / leetcode

:question: My LeetCode solutions, currently written in Javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My LeetCode

Build Status

Description

This is the repo of my LeetCode solutions, and currently I just use Javascript to solve the questions, maybe in the future, I will use other languages I like to get the ALL PASS grade.

Features

First of all, you need to install all dependencis:

npm i

Fetch Problems in Terminal

By executing the command you can browse all the problems in your terminal, and select any one to solve.

npm run f:question

Test Cases

I've used Mocha and Chai to test the programs, the test cases are defined in the problems/*/test-cases.js:

npm test                    # test all test cases
npm test [problem number]   # test single problem

Submissions

Sequence Title Difficulty Submission
1 Two Sum Easy 001_two-sum
2 Add Two Numbers Medium 002_add-two-numbers
3 Longest Substring Without Repeating Characters Medium 003_longest-substring-without-repeating-characters
5 Longest Palindromic Substring Medium 005_longest-palindromic-substring
6 ZigZag Conversion Medium 006_zigzag-conversion
7 Reverse Integer Easy 007_reverse-integer
8 String to Integer (atoi) Medium 008_string-to-integer-atoi
9 Palindrome Number Easy 009_palindrome-number
10 Regular Expression Matching Hard 010_regular-expression-matching
11 Container With Most Water Medium 011_container-with-most-water
12 Integer to Roman Medium 012_integer-to-roman
13 Roman to Integer Easy 013_roman-to-integer
14 Longest Common Prefix Easy 014_longest-common-prefix
15 3Sum Medium 015_3sum
16 3Sum Closest Medium 016_3sum-closest
17 Letter Combinations of a Phone Number Medium 017_letter-combinations-of-a-phone-number
18 4Sum Medium 018_4sum
19 Remove Nth Node From End of List Medium 019_remove-nth-node-from-end-of-list
20 Valid Parentheses Easy 020_valid-parentheses
21 Merge Two Sorted Lists Easy 021_merge-two-sorted-lists
22 Generate Parentheses Medium 022_generate-parentheses
23 Merge k Sorted Lists Hard 023_merge-k-sorted-lists
24 Swap Nodes in Pairs Medium 024_swap-nodes-in-pairs
26 Remove Duplicates from Sorted Array Easy 026_remove-duplicates-from-sorted-array
27 Remove Element Easy 027_remove-element
28 Implement strStr() Easy 028_implement-strstr
29 Divide Two Integers Medium 029_divide-two-integers
34 Search for a Range Medium 034_search-for-a-range
35 Search Insert Position Easy 035_search-insert-position
38 Count and Say Easy 038_count-and-say
39 Combination Sum Medium 039_combination-sum
41 First Missing Positive Hard 041_first-missing-positive
46 Permutations Medium 046_permutations
48 Rotate Image Medium 048_rotate-image
49 Group Anagrams Medium 049_group-anagrams
53 Maximum Subarray Easy 053_maximum-subarray
54 Spiral Matrix Medium 054_spiral-matrix
55 Jump Game Medium 055_jump-game
58 Length of Last Word Easy 058_length-of-last-word
59 Spiral Matrix II Medium 059_spiral-matrix-ii
60 Permutation Sequence Medium 060_permutation-sequence
61 Rotate List Medium 061_rotate-list
62 Unique Paths Medium 062_unique-paths
63 Unique Paths II Medium 063_unique-paths-ii
64 Minimum Path Sum Medium 064_minimum-path-sum
68 Text Justification Hard 068_text-justification
69 Sqrt(x) Easy 069_sqrtx
71 Simplify Path Medium 071_simplify-path
73 Set Matrix Zeroes Medium 073_set-matrix-zeroes
75 Sort Colors Medium 075_sort-colors
77 Combinations Medium 077_combinations
78 Subsets Medium 078_subsets
79 Word Search Medium 079_word-search
80 Remove Duplicates from Sorted Array II Medium 080_remove-duplicates-from-sorted-array-ii
83 Remove Duplicates from Sorted List Easy 083_remove-duplicates-from-sorted-list
88 Merge Sorted Array Easy 088_merge-sorted-array
89 Gray Code Medium 089_gray-code
90 Subsets II Medium 090_subsets-ii
91 Decode Ways Medium 091_decode-ways
92 Reverse Linked List II Medium 092_reverse-linked-list-ii
93 Restore IP Addresses Medium 093_restore-ip-addresses
94 Binary Tree Inorder Traversal Medium 094_binary-tree-inorder-traversal
98 Validate Binary Search Tree Medium 098_validate-binary-search-tree
100 Same Tree Easy 100_same-tree
101 Symmetric Tree Easy 101_symmetric-tree
102 Binary Tree Level Order Traversal Medium 102_binary-tree-level-order-traversal
111 Minimum Depth of Binary Tree Easy 111_minimum-depth-of-binary-tree
112 Path Sum Easy 112_path-sum
113 Path Sum II Medium 113_path-sum-ii
114 Flatten Binary Tree to Linked List Medium 114_flatten-binary-tree-to-linked-list
116 Populating Next Right Pointers in Each Node Medium 116_populating-next-right-pointers-in-each-node
118 Pascal's Triangle Easy 118_pascals-triangle
119 Pascal's Triangle II Easy 119_pascals-triangle-ii
120 Triangle Medium 120_triangle
121 Best Time to Buy and Sell Stock Easy 121_best-time-to-buy-and-sell-stock
122 Best Time to Buy and Sell Stock II Easy 122_best-time-to-buy-and-sell-stock-ii
125 Valid Palindrome Easy 125_valid-palindrome
129 Sum Root to Leaf Numbers Medium 129_sum-root-to-leaf-numbers
130 Surrounded Regions Medium 130_surrounded-regions
131 Palindrome Partitioning Medium 131_palindrome-partitioning
134 Gas Station Medium 134_gas-station
136 Single Number Easy 136_single-number
137 Single Number II Medium 137_single-number-ii
139 Word Break Medium 139_word-break
141 Linked List Cycle Easy 141_linked-list-cycle
142 Linked List Cycle II Medium 142_linked-list-cycle-ii
143 Reorder List Medium 143_reorder-list
144 Binary Tree Preorder Traversal Medium 144_binary-tree-preorder-traversal
145 Binary Tree Postorder Traversal Hard 145_binary-tree-postorder-traversal
147 Insertion Sort List Medium 147_insertion-sort-list
150 Evaluate Reverse Polish Notation Medium 150_evaluate-reverse-polish-notation
151 Reverse Words in a String Medium 151_reverse-words-in-a-string
152 Maximum Product Subarray Medium 152_maximum-product-subarray
153 Find Minimum in Rotated Sorted Array Medium 153_find-minimum-in-rotated-sorted-array
155 Min Stack Easy 155_min-stack
160 Intersection of Two Linked Lists Easy 160_intersection-of-two-linked-lists
162 Find Peak Element Medium 162_find-peak-element
165 Compare Version Numbers Medium 165_compare-version-numbers
168 Excel Sheet Column Title Easy 168_excel-sheet-column-title
169 Majority Element Easy 169_majority-element
171 Excel Sheet Column Number Easy 171_excel-sheet-column-number
172 Factorial Trailing Zeroes Easy 172_factorial-trailing-zeroes
179 Largest Number Medium 179_largest-number
187 Repeated DNA Sequences Medium 187_repeated-dna-sequences
189 Rotate Array Easy 189_rotate-array
190 Reverse Bits Easy 190_reverse-bits
191 Number of 1 Bits Easy 191_number-of-1-bits
198 House Robber Easy 198_house-robber
199 Binary Tree Right Side View Medium 199_binary-tree-right-side-view
200 Number of Islands Medium 200_number-of-islands
201 Bitwise AND of Numbers Range Medium 201_bitwise-and-of-numbers-range
202 Happy Number Easy 202_happy-number
203 Remove Linked List Elements Easy 203_remove-linked-list-elements
204 Count Primes Easy 204_count-primes
205 Isomorphic Strings Easy 205_isomorphic-strings
206 Reverse Linked List Easy 206_reverse-linked-list
207 Course Schedule Medium 207_course-schedule
209 Minimum Size Subarray Sum Medium 209_minimum-size-subarray-sum
215 Kth Largest Element in an Array Medium 215_kth-largest-element-in-an-array
216 Combination Sum III Medium 216_combination-sum-iii
217 Contains Duplicate Easy 217_contains-duplicate
219 Contains Duplicate II Easy 219_contains-duplicate-ii
220 Contains Duplicate III Medium 220_contains-duplicate-iii
221 Maximal Square Medium 221_maximal-square
223 Rectangle Area Medium 223_rectangle-area
224 Basic Calculator Hard 224_basic-calculator
226 Invert Binary Tree Easy 226_invert-binary-tree
227 Basic Calculator II Medium 227_basic-calculator-ii
228 Summary Ranges Medium 228_summary-ranges
229 Majority Element II Medium 229_majority-element-ii
231 Power of Two Easy 231_power-of-two
234 Palindrome Linked List Easy 234_palindrome-linked-list
235 Lowest Common Ancestor of a Binary Search Tree Easy 235_lowest-common-ancestor-of-a-binary-search-tree
237 Delete Node in a Linked List Easy 237_delete-node-in-a-linked-list
238 Product of Array Except Self Medium 238_product-of-array-except-self
240 Search a 2D Matrix II Medium 240_search-a-2d-matrix-ii
242 Valid Anagram Easy 242_valid-anagram
257 Binary Tree Paths Easy 257_binary-tree-paths
258 Add Digits Easy 258_add-digits
263 Ugly Number Easy 263_ugly-number
264 Ugly Number II Medium 264_ugly-number-ii
268 Missing Number Easy 268_missing-number
274 H-Index Medium 274_h-index
275 H-Index II Medium 275_h-index-ii
278 First Bad Version Easy 278_first-bad-version
279 Perfect Squares Medium 279_perfect-squares
283 Move Zeroes Easy 283_move-zeroes
289 Game of Life Medium 289_game-of-life
290 Word Pattern Easy 290_word-pattern
292 Nim Game Easy 292_nim-game
299 Bulls and Cows Medium 299_bulls-and-cows
300 Longest Increasing Subsequence Medium 300_longest-increasing-subsequence
303 Range Sum Query - Immutable Easy 303_range-sum-query-immutable
304 Range Sum Query 2D - Immutable Medium 304_range-sum-query-2d-immutable
306 Additive Number Medium 306_additive-number
307 Range Sum Query - Mutable Medium 307_range-sum-query-mutable
318 Maximum Product of Word Lengths Medium 318_maximum-product-of-word-lengths
322 Coin Change Medium 322_coin-change
326 Power of Three Easy 326_power-of-three
328 Odd Even Linked List Medium 328_odd-even-linked-list
332 Reconstruct Itinerary Medium 332_reconstruct-itinerary
334 Increasing Triplet Subsequence Medium 334_increasing-triplet-subsequence
338 Counting Bits Medium 338_counting-bits
343 Integer Break Medium 343_integer-break
344 Reverse String Easy 344_reverse-string
345 Reverse Vowels of a String Easy 345_reverse-vowels-of-a-string
347 Top K Frequent Elements Medium 347_top-k-frequent-elements
349 Intersection of Two Arrays Easy 349_intersection-of-two-arrays
350 Intersection of Two Arrays II Easy 350_intersection-of-two-arrays-ii
367 Valid Perfect Square Easy 367_valid-perfect-square
368 Largest Divisible Subset Medium 368_largest-divisible-subset
378 Kth Smallest Element in a Sorted Matrix Medium 378_kth-smallest-element-in-a-sorted-matrix
383 Ransom Note Easy 383_ransom-note
386 Lexicographical Numbers Medium 386_lexicographical-numbers
387 First Unique Character in a String Easy 387_first-unique-character-in-a-string
388 Longest Absolute File Path Medium 388_longest-absolute-file-path
389 Find the Difference Easy 389_find-the-difference
392 Is Subsequence Medium 392_is-subsequence
394 Decode String Medium 394_decode-string
397 Integer Replacement Medium 397_integer-replacement
399 Evaluate Division Medium 399_evaluate-division
401 Binary Watch Easy 401_binary-watch
404 Sum of Left Leaves Easy 404_sum-of-left-leaves
405 Convert a Number to Hexadecimal Easy 405_convert-a-number-to-hexadecimal
406 Queue Reconstruction by Height Medium 406_queue-reconstruction-by-height
409 Longest Palindrome Easy 409_longest-palindrome
412 Fizz Buzz Easy 412_fizz-buzz
413 Arithmetic Slices Medium 413_arithmetic-slices
415 Add Strings Easy 415_add-strings
416 Partition Equal Subset Sum Medium 416_partition-equal-subset-sum
417 Pacific Atlantic Water Flow Medium 417_pacific-atlantic-water-flow
419 Battleships in a Board Medium 419_battleships-in-a-board
423 Reconstruct Original Digits from English Medium 423_reconstruct-original-digits-from-english
434 Number of Segments in a String Easy 434_number-of-segments-in-a-string
438 Find All Anagrams in a String Easy 438_find-all-anagrams-in-a-string
441 Arranging Coins Easy 441_arranging-coins
442 Find All Duplicates in an Array Medium 442_find-all-duplicates-in-an-array
453 Minimum Moves to Equal Array Elements Easy 453_minimum-moves-to-equal-array-elements
485 Max Consecutive Ones Easy 485_max-consecutive-ones
492 Construct the Rectangle Easy 492_construct-the-rectangle
494 Target Sum Medium 494_target-sum
496 Next Greater Element I Easy 496_next-greater-element-i
506 Relative Ranks Easy 506_relative-ranks
508 Most Frequent Subtree Sum Medium 508_most-frequent-subtree-sum
513 Find Bottom Left Tree Value Medium 513_find-bottom-left-tree-value
515 Find Largest Value in Each Tree Row Medium 515_find-largest-value-in-each-tree-row
520 Detect Capital Easy 520_detect-capital
529 Minesweeper Medium 529_minesweeper
530 Minimum Absolute Difference in BST Easy 530_minimum-absolute-difference-in-bst
538 Convert BST to Greater Tree Easy 538_convert-bst-to-greater-tree
539 Minimum Time Difference Medium 539_minimum-time-difference
542 01 Matrix Medium 542_01-matrix
560 Subarray Sum Equals K Medium 560_subarray-sum-equals-k
561 Array Partition I Easy 561_array-partition-i
563 Binary Tree Tilt Easy 563_binary-tree-tilt
566 Reshape the Matrix Easy 566_reshape-the-matrix
567 Permutation in String Medium 567_permutation-in-string
581 Shortest Unsorted Continuous Subarray Easy 581_shortest-unsorted-continuous-subarray
592 Fraction Addition and Subtraction Medium 592_fraction-addition-and-subtraction
593 Valid Square Medium 593_valid-square
594 Longest Harmonious Subsequence Easy 594_longest-harmonious-subsequence
617 Merge Two Binary Trees Easy 617_merge-two-binary-trees
646 Maximum Length of Pair Chain Medium 646_maximum-length-of-pair-chain
655 Print Binary Tree Medium 655_print-binary-tree
662 Maximum Width of Binary Tree Medium 662_maximum-width-of-binary-tree
669 Trim a Binary Search Tree Easy 669_trim-a-binary-search-tree
670 Maximum Swap Medium 670_maximum-swap
671 Second Minimum Node In a Binary Tree Easy 671_second-minimum-node-in-a-binary-tree
673 Number of Longest Increasing Subsequence Medium 673_number-of-longest-increasing-subsequence
674 Longest Continuous Increasing Subsequence Easy 674_longest-continuous-increasing-subsequence
676 Implement Magic Dictionary Medium 676_implement-magic-dictionary
677 Map Sum Pairs Medium 677_map-sum-pairs
678 Valid Parenthesis String Medium 678_valid-parenthesis-string
680 Valid Palindrome II Easy 680_valid-palindrome-ii
682 Baseball Game Easy 682_baseball-game
687 Longest Univalue Path Easy 687_longest-univalue-path
693 Binary Number with Alternating Bits Easy 693_binary-number-with-alternating-bits
695 Max Area of Island Easy 695_max-area-of-island
698 Partition to K Equal Sum Subsets Medium 698_partition-to-k-equal-sum-subsets
713 Subarray Product Less Than K Medium 713_subarray-product-less-than-k
714 Best Time to Buy and Sell Stock with Transaction Fee Medium 714_best-time-to-buy-and-sell-stock-with-transaction-fee

About

:question: My LeetCode solutions, currently written in Javascript

License:MIT License


Languages

Language:JavaScript 100.0%