Skip to content

LeetCode with TypeScript

License

Notifications You must be signed in to change notification settings

brahinets/leetcode-js

Repository files navigation

LeetCode with JavaScript: give your brain a workout

image

All Solutions
  1. 1. Two Sum
  2. 2. Add Two Numbers
  3. 3. Longest Substring Without Repeating Characters
  4. 4. Median of Two Sorted Arrays
  5. 5. Longest Palindromic Substring
  6. 6. Zigzag Conversion
  7. 7. Reverse Integer
  8. 8. String to Integer (atoi)
  9. 9. Palindrome Number
  10. 11. Container With Most Water
  11. 12. Integer to Roman
  12. 13. Roman to Integer
  13. 14. Longest Common Prefix
  14. 15. 3Sum
  15. 16. 3Sum Closest
  16. 17. Letter Combinations of a Phone Number
  17. 19. Remove Nth Node From End of List
  18. 20. Valid Parentheses
  19. 21. Merge Two Sorted Lists
  20. 22. Generate Parentheses
  21. 23. Merge k Sorted Lists
  22. 24. Swap Nodes in Pairs
  23. 26. Remove Duplicates from Sorted Array
  24. 27. Remove Element
  25. 28. Find the Index of the First Occurrence in a String
  26. 33. Search in Rotated Sorted Array
  27. 34. Find First and Last Position of Element in Sorted Array
  28. 35. Search Insert Position
  29. 36. Valid Sudoku
  30. 41. First Missing Positive
  31. 42. Trapping Rain Water
  32. 49. Group Anagrams
  33. 50. Pow
  34. 54. Spiral Matrix
  35. 57. Insert Interval
  36. 58. Length of Last Word
  37. 59. Spiral Matrix II
  38. 62. Unique Paths
  39. 67. Add Binary
  40. 70. Climbing Stairs
  41. 71. Simplify Path
  42. 74. Search a 2D Matrix
  43. 75. Sort Colors
  44. 76. Minimum Window Substring
  45. 77. Combinations
  46. 78. Subsets
  47. 79. Word Search
  48. 85. Maximal Rectangle
  49. 86. Partition List
  50. 91. Decode Ways
  51. 94. Binary Tree Inorder Traversal
  52. 98. Validate Binary Search Tree
  53. 100. Same Tree
  54. 101. Symmetric Tree
  55. 102. Binary Tree Level Order Traversal
  56. 103. Binary Tree Zigzag Level Order Traversal
  57. 104. Maximum Depth of Binary Tree
  58. 109. Convert Sorted List to Binary Search Tree
  59. 110. Balanced Binary Tree
  60. 111. Minimum Depth of Binary Tree
  61. 119. Pascal's Triangle II
  62. 121. Best Time to Buy and Sell Stock
  63. 125. Valid Palindrome
  64. 128. Longest Consecutive Sequence
  65. 129. Sum Root to Leaf Numbers
  66. 131. Palindrome Partitioning
  67. 137. Single Number II
  68. 139. Word Break
  69. 140. Word Break II
  70. 141. Linked List Cycle
  71. 142. Linked List Cycle II
  72. 143. Reorder List
  73. 146. LRU Cache
  74. 150. Evaluate Reverse Polish Notation
  75. 153. Find Minimum in Rotated Sorted Array
  76. 155. Min Stack
  77. 167. Two Sum II - Input Array Is Sorted
  78. 168. Excel Sheet Column Title
  79. 169. Majority Element
  80. 190. Reverse Bits
  81. 191. Number of 1 Bits
  82. 198. House Robber
  83. 199. Binary Tree Right Side View
  84. 200. Number of Islands
  85. 201. Bitwise AND of Numbers Range
  86. 205. Isomorphic Strings
  87. 206. Reverse Linked List
  88. 208. Implement Trie (Prefix Tree)
  89. 211. Design Add and Search Words Data Structure
  90. 215. Kth Largest Element in an Array
  91. 217. Contains Duplicate
  92. 225. Implement Stack using Queues
  93. 226. Invert Binary Tree
  94. 228. Summary Ranges
  95. 229. Majority Element II
  96. 231. Power of Two
  97. 232. Implement Queue using Stacks
  98. 234. Palindrome Linked List
  99. 235. Lowest Common Ancestor of a Binary Search Tree
  100. 237. Delete Node in a Linked List
  101. 238. Product of Array Except Self
  102. 239. Sliding Window Maximum
  103. 242. Valid Anagram
  104. 258. Add Digits
  105. 260. Single Number III
  106. 268. Missing Number
  107. 278. First Bad Version
  108. 279. Perfect Squares
  109. 287. Find the Duplicate Number
  110. 299. Bulls and Cows
  111. 300. Longest Increasing Subsequence
  112. 310. Minimum Height Trees
  113. 316. Remove Duplicate Letters
  114. 319. Bulb Switcher
  115. 330. Patching Array
  116. 342. Power of Four
  117. 343. Integer Break
  118. 344. Reverse String
  119. 347. Top K Frequent Elements
  120. 349. Intersection of Two Arrays
  121. 368. Largest Divisible Subset
  122. 373. Find K Pairs with Smallest Sums
  123. 380. Insert Delete GetRandom O(1)
  124. 382. Linked List Random Node
  125. 383. Ransom Note
  126. 387. First Unique Character in a String
  127. 392. Is Subsequence
  128. 394. Decode String
  129. 399. Evaluate Division
  130. 402. Remove K Digits
  131. 403. Frog Jump
  132. 404. Sum of Left Leaves
  133. 409. Longest Palindrome
  134. 424. Longest Repeating Character Replacement
  135. 435. Non-overlapping Intervals
  136. 438. Find All Anagrams in a String
  137. 442. Find All Duplicates in an Array
  138. 443. String Compression
  139. 445. Add Two Numbers II
  140. 446. Arithmetic Slices II - Subsequence
  141. 451. Sort Characters By Frequency
  142. 452. Minimum Number of Arrows to Burst Balloons
  143. 455. Assign Cookies
  144. 458. Poor Pigs
  145. 459. Repeated Substring Pattern
  146. 463. Island Perimeter
  147. 486. Predict the Winner
  148. 501. Find Mode in Binary Search Tree
  149. 502. IPO
  150. 506. Relative Ranks
  151. 509. Fibonacci Number
  152. 513. Find Bottom Left Tree Value
  153. 514. Freedom Trail
  154. 515. Find Largest Value in Each Tree Row
  155. 516. Longest Palindromic Subsequence
  156. 518. Coin Change II
  157. 523. Continuous Subarray Sum
  158. 525. Contiguous Array
  159. 530. Minimum Absolute Difference in BST
  160. 540. Single Element in a Sorted Array
  161. 543. Diameter of Binary Tree
  162. 547. Number of Provinces
  163. 552. Student Attendance Record II
  164. 572. Subtree of Another Tree
  165. 576. Out of Boundary Paths
  166. 589. N-ary Tree Preorder Traversal
  167. 605. Can Place Flowers
  168. 606. Construct String from Binary Tree
  169. 621. Task Scheduler
  170. 623. Add One Row to Tree
  171. 629. K Inverse Pairs Array
  172. 633. Sum of Square Numbers
  173. 645. Set Mismatch
  174. 647. Palindromic Substrings
  175. 648. Replace Words
  176. 649. Dota2 Senate
  177. 661. Image Smoother
  178. 678. Valid Parenthesis String
  179. 688. Knight Probability in Chessboard
  180. 692. Top K Frequent Words
  181. 703. Kth Largest Element in a Stream
  182. 704. Binary Search
  183. 705. Design HashSet
  184. 706. Design HashMap
  185. 712. Minimum ASCII Delete Sum for Two Strings
  186. 713. Subarray Product Less Than K
  187. 714. Best Time to Buy and Sell Stock with Transaction Fee
  188. 724. Find Pivot Index
  189. 733. Flood Fill
  190. 735. Asteroid Collision
  191. 739. Daily Temperatures
  192. 744. Find Smallest Letter Greater Than Target
  193. 746. Min Cost Climbing Stairs
  194. 752. Open the Lock
  195. 767. Reorganize String
  196. 779. K-th Symbol in Grammar
  197. 783. Minimum Distance Between BST Nodes
  198. 786. K-th Smallest Prime Fraction
  199. 787. Cheapest Flights Within K Stops
  200. 791. Custom Sort String
  201. 802. Find Eventual Safe States
  202. 808. Soup Servings
  203. 834. Sum of Distances in Tree
  204. 844. Backspace String Compare
  205. 846. Hand of Straights
  206. 852. Peak Index in a Mountain Array
  207. 853. Car Fleet
  208. 857. Minimum Cost to Hire K Workers
  209. 859. Buddy Strings
  210. 861. Score After Flipping Matrix
  211. 863. All Nodes Distance K in Binary Tree
  212. 867. Transpose Matrix
  213. 872. Leaf-Similar Trees
  214. 875. Koko Eating Bananas
  215. 876. Middle of the Linked List
  216. 880. Decoded String at Index
  217. 881. Boats to Save People
  218. 907. Sum of Subarray Minimums
  219. 912. Sort an Array
  220. 920. Number of Music Playlists
  221. 930. Binary Subarrays With Sum
  222. 931. Minimum Falling Path Sum
  223. 934. Shortest Bridge
  224. 935. Knight Dialer
  225. 938. Range Sum of BST
  226. 945. Minimum Increment to Make Array Unique
  227. 946. Validate Stack Sequences
  228. 948. Bag of Tokens
  229. 950. Reveal Cards In Increasing Order
  230. 956. Tallest Billboard
  231. 958. Check Completeness of a Binary Tree
  232. 974. Subarray Sums Divisible by K
  233. 977. Squares of a Sorted Array
  234. 979. Distribute Coins in Binary Tree
  235. 981. Time Based Key-Value Store
  236. 988. Smallest String Starting From Leaf
  237. 989. Add to Array-Form of Integer
  238. 992. Subarrays with K Different Integers
  239. 997. Find the Town Judge
  240. 1002. Find Common Characters
  241. 1020. Number of Enclaves
  242. 1026. Maximum Difference Between Node and Ancestor
  243. 1027. Longest Arithmetic Subsequence
  244. 1035. Uncrossed Lines
  245. 1043. Partition Array for Maximum Sum
  246. 1046. Last Stone Weight
  247. 1074. Number of Submatrices That Sum to Target
  248. 1091. Shortest Path in Binary Matrix
  249. 1122. Relative Sort Array
  250. 1125. Smallest Sufficient Team
  251. 1137. N-th Tribonacci Number
  252. 1143. Longest Common Subsequence
  253. 1146. Snapshot Array
  254. 1155. Number of Dice Rolls With Target Sum
  255. 1160. Find Words That Can Be Formed by Characters
  256. 1161. Maximum Level Sum of a Binary Tree
  257. 1171. Remove Zero Sum Consecutive Nodes from Linked List
  258. 1207. Unique Number of Occurrences
  259. 1208. Get Equal Substrings Within Budget
  260. 1218. Longest Arithmetic Subsequence of Given Difference
  261. 1219. Path with Maximum Gold
  262. 1232. Check If It Is a Straight Line
  263. 1235. Maximum Profit in Job Scheduling
  264. 1239. Maximum Length of a Concatenated String with Unique Characters
  265. 1249. Minimum Remove to Make Valid Parentheses
  266. 1254. Number of Closed Islands
  267. 1255. Maximum Score Words Formed by Letters
  268. 1266. Minimum Time Visiting All Points
  269. 1287. Element Appearing More Than 25% In Sorted Array
  270. 1289. Minimum Falling Path Sum II
  271. 1291. Sequential Digits
  272. 1312. Minimum Insertion Steps to Make a String Palindrome
  273. 1318. Minimum Flips to Make a OR b Equal to c
  274. 1325. Delete Leaves With a Given Value
  275. 1335. Minimum Difficulty of a Job Schedule
  276. 1347. Minimum Number of Steps to Make Two Strings Anagram
  277. 1351. Count Negative Numbers in a Sorted Matrix
  278. 1356. Sort Integers by The Number of 1 Bits
  279. 1372. Longest ZigZag Path in a Binary Tree
  280. 1396. Design Underground System
  281. 1404. Number of Steps to Reduce a Number in Binary Representation to One
  282. 1424. Diagonal Traverse II
  283. 1431. Kids With the Greatest Number of Candies
  284. 1436. Destination City
  285. 1422. Maximum Score After Splitting a String
  286. 1442. Count Triplets That Can Form Two Arrays of Equal XOR
  287. 1448. Count Good Nodes in Binary Tree
  288. 1456. Maximum Number of Vowels in a Substring of Given Length
  289. 1457. Pseudo-Palindromic Paths in a Binary Tree
  290. 1463. Cherry Pickup II
  291. 1464. Maximum Product of Two Elements in an Array
  292. 1472. Design Browser History
  293. 1480. Running Sum of 1d Array
  294. 1481. Least Number of Unique Integers after K Removals
  295. 1491. Average Salary Excluding the Minimum and Maximum Salary
  296. 1493. Longest Subarray of 1's After Deleting One Element
  297. 1496. Path Crossing
  298. 1498. Number of Subsequences That Satisfy the Given Sum Condition
  299. 1502. Can Make Arithmetic Progression From Sequence
  300. 1512. Number of Good Pairs
  301. 1514. Path with Maximum Probability
  302. 1523. Count Odd Numbers in an Interval Range
  303. 1531. String Compression II
  304. 1539. Kth Missing Positive Number
  305. 1544. Make The String Great
  306. 1561. Maximum Number of Coins You Can Get
  307. 1572. Matrix Diagonal Sum
  308. 1575. Count All Possible Routes
  309. 1578. Minimum Time to Make Rope Colorful
  310. 1582. Special Positions in a Binary Matrix
  311. 1603. Design Parking System
  312. 1608. Special Array With X Elements Greater Than or Equal X
  313. 1609. Even Odd Tree
  314. 1611. Minimum One Bit Operations to Make Integers Zero
  315. 1614. Maximum Nesting Depth of the Parentheses
  316. 1624. Largest Substring Between Two Equal Characters
  317. 1630. Arithmetic Subarrays
  318. 1637. Widest Vertical Area Between Two Points Containing No Points
  319. 1642. Furthest Building You Can Reach
  320. 1657. Determine if Two Strings Are Close
  321. 1662. Check If Two String Arrays are Equivalent
  322. 1669. Merge In Between Linked Lists
  323. 1685. Sum of Absolute Differences in a Sorted Array
  324. 1688. Count of Matches in Tournament
  325. 1700. Number of Students Unable to Eat Lunch
  326. 1704. Determine if String Halves Are Alike
  327. 1716. Calculate Money in Leetcode Bank
  328. 1721. Swapping Nodes in a Linked List
  329. 1727. Largest Submatrix With Rearrangements
  330. 1732. Find the Highest Altitude
  331. 1750. Minimum Length of String After Deleting Similar Ends
  332. 1758. Minimum Changes To Make Alternating Binary String
  333. 1759. Count Number of Homogenous Substrings
  334. 1768. Merge Strings Alternately
  335. 1793. Maximum Score of a Good Subarray
  336. 1799. Maximize Score After N Operations
  337. 1802. Maximum Value at a Given Index in a Bounded Array
  338. 1814. Count Nice Pairs in an Array
  339. 1822. Sign of the Product of an Array
  340. 1838. Frequency of the Most Frequent Element
  341. 1845. Seat Reservation Manager
  342. 1846. Maximum Element After Decreasing and Rearranging
  343. 1863. Sum of All Subset XOR Totals
  344. 1870. Minimum Speed to Arrive on Time
  345. 1877. Minimize Maximum Pair Sum in Array
  346. 1887. Reduction Operations to Make the Array Elements Equal
  347. 1897. Redistribute Characters to Make All Strings Equal
  348. 1903. Largest Odd Number in String
  349. 1913. Maximum Product Difference Between Two Pairs
  350. 1915. Number of Wonderful Substrings
  351. 1921. Eliminate Maximum Number of Monsters
  352. 1930. Unique Length-3 Palindromic Subsequences
  353. 1971. Find if Path Exists in Graph
  354. 1980. Find Unique Binary String
  355. 1992. Find All Groups of Farmland
  356. 2000. Reverse Prefix of Word
  357. 2024. Maximize the Confusion of an Exam
  358. 2037. Minimum Number of Moves to Seat Everyone
  359. 2073. Time Needed to Buy Tickets
  360. 2090. K Radius Subarray Averages
  361. 2092. Find All People With Secret
  362. 2108. Find First Palindromic String in the Array
  363. 2125. Number of Laser Beams in a Bank
  364. 2130. Maximum Twin Sum of a Linked List
  365. 2140. Solving Questions With Brainpower
  366. 2147. Number of Ways to Divide a Long Corridor
  367. 2149. Rearrange Array Elements by Sign
  368. 2187. Minimum Time to Complete Trips
  369. 2191. Sort the Jumbled Numbers
  370. 2215. Find the Difference of Two Arrays
  371. 2225. Find Players With Zero or One Losses
  372. 2235. Add Two Integers
  373. 2236. Root Equals Sum of Children
  374. 2264. Largest 3-Same-Digit Number in String
  375. 2265. Count Nodes Equal to Average of Subtree
  376. 2300. Successful Pairs of Spells and Potions
  377. 2305. Fair Distribution of Cookies
  378. 2331. Evaluate Boolean Binary Tree
  379. 2336. Smallest Number in Infinite Set
  380. 2348. Number of Zero-Filled Sub-arrays
  381. 2352. Equal Row and Column Pairs
  382. 2353. Design a Food Rating System
  383. 2370. Longest Ideal Subsequence
  384. 2373. Largest Local Values in a Matrix
  385. 2385. Amount of Time for Binary Tree to Be Infected
  386. 2390. Removing Stars From a String
  387. 2391. Minimum Amount of Time to Collect Garbage
  388. 2405. Optimal Partition of String
  389. 2402. Meeting Rooms III
  390. 2439. Minimize Maximum of Array
  391. 2441. Largest Positive Integer That Exists With Its Negative
  392. 2444. Count Subarrays With Fixed Bounds
  393. 2448. Minimum Cost to Make Array Equal
  394. 2462. Total Cost to Hire K Workers
  395. 2466. Count Ways To Build Good Strings
  396. 2482. Difference Between Ones and Zeros in Row and Column
  397. 2485. Find the Pivot Integer
  398. 2486. Append Characters to String to Make Subsequence
  399. 2487. Remove Nodes From Linked List
  400. 2540. Minimum Common Value
  401. 2542. Maximum Subsequence Score
  402. 2551. Put Marbles in Bags
  403. 2597. The Number of Beautiful Subsets
  404. 2610. Convert an Array Into a 2D Array With Conditions
  405. 2616. Minimize the Maximum Difference of Pairs
  406. 2642. Design Graph With Shortest Path Calculator
  407. 2706. Buy Two Chocolates
  408. 2709. Greatest Common Divisor Traversal
  409. 2785. Sort Vowels in a String
  410. 2812. Find the Safest Path in a Grid
  411. 2816. Double a Number Represented as a Linked List
  412. 2849. Determine if a Cell Is Reachable at a Given Time
  413. 2864. Maximum Odd Binary Number
  414. 2870. Minimum Number of Operations to Make Array Empty
  415. 2958. Length of Longest Subarray With at Most K Frequency
  416. 2962. Count Subarrays Where Max Element Appears at Least K Times
  417. 2966. Divide Array Into Arrays With Max Difference
  418. 2971. Find Polygon With the Largest Perimeter
  419. 2997. Minimum Number of Operations to Make Array XOR Equal to K
  420. 3005. Count Elements With Maximum Frequency
  421. 3068. Find the Maximum Sum of Node Values
  422. 3075. Maximize Happiness of Selected Children
  423. 3110. Score of a String