Skip to content

jawwad/leetcode

 
 

Repository files navigation

Leetcode solutions for 🚀 NeetCode.io

This repo hosts the solutions found on NeetCode.io including the solutions shown on the NeetCode YouTube channel. The site will periodically be updated with new solutions from this repo!


Solutions from these languages will be linked from NeetCode.io:

  • Python
  • C++
  • Java
  • Javascript

Solutions are also welcome for any other supported language on leetcode.com!

Contributing

Please read the contributing guidlines before opening a PR

To contribute, please fork this repo and open a PR adding a missing solution from the supported languages.

If you would like to have collaborator permissions on the repo to merge your own PRs or review others' PRs please let me know.

Credits

Missing Solutions

Arrays & Hashing

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
217 - Contains Duplicate
242 - Valid Anagram
1299 - Replace Elements With Greatest Element On Right Side
392 - Is Subsequence
58 - Length of Last Word
1 - Two Sum
14 - Longest Common Prefix
49 - Group Anagrams
118 - Pascals Triangle
27 - Remove Element
929 - Unique Email Addresses
205 - Isomorphic Strings
605 - Can Place Flowers
169 - Majority Element
496 - Next Greater Element I
724 - Find Pivot Index
448 - Find All Numbers Disappeared In An Array
1189 - Maximum Number of Balloons
290 - Word Pattern
347 - Top K Frequent Elements
238 - Product of Array Except Self
36 - Valid Sudoku
271 - Encode And Decode Strings
128 - Longest Consecutive Sequence
75 - Sort Colors
535 - Encode And Decode Tinyurl
554 - Brick Wall
122 - Best Time to Buy And Sell Stock II
560 - Subarray Sum Equals K
1930 - Unique Length 3 Palindromic Subsequences
1963 - Minimum Number of Swaps to Make The String Balanced
2001 - Number of Pairs of Interchangeable Rectangles
2002 - Maximum Product of The Length of Two Palindromic Subsequences
2017 - Grid Game
438 - Find All Anagrams In a String
28 - Find The Index of The First Occurrence In a String
280 - Wiggle Sort
179 - Largest Number
523 - Continuous Subarray Sum
838 - Push Dominoes
187 - Repeated Dna Sequences
380 - Insert Delete Get Random O(1)
1461 - Check if a String Contains All Binary Codes of Size K
304 - Range Sum Query 2D Immutable
665 - Non Decreasing Array
41 - First Missing Positive

Two Pointers

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
125 - Valid Palindrome
680 - Valid Palindrome II
1984 - Minimum Difference Between Highest And Lowest of K Scores
344 - Reverse String
88 - Merge Sorted Array
283 - Move Zeroes
26 - Remove Duplicates From Sorted Array
167 - Two Sum II Input Array Is Sorted
15 - 3Sum
18 - 4Sum
11 - Container With Most Water
1498 - Number of Subsequences That Satisfy The Given Sum Condition
189 - Rotate Array
1968 - Array With Elements Not Equal to Average of Neighbors
881 - Boats to Save People
42 - Trapping Rain Water

Sliding Window

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
121 - Best Time to Buy And Sell Stock
3 - Longest Substring Without Repeating Characters
424 - Longest Repeating Character Replacement
567 - Permutation In String
1838 - Frequency of The Most Frequent Element
1888 - Minimum Number of Flips to Make The Binary String Alternating
209 - Minimum Size Subarray Sum
658 - Find K Closest Elements
76 - Minimum Window Substring
239 - Sliding Window Maximum

Stack

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
20 - Valid Parentheses
682 - Baseball Game
225 - Implement Stack Using Queues
155 - Min Stack
150 - Evaluate Reverse Polish Notation
22 - Generate Parentheses
735 - Asteroid Collision
739 - Daily Temperatures
901 - Online Stock Span
853 - Car Fleet
71 - Simplify Path
394 - Decode String
402 - Remove K Digits
1209 - Remove All Adjacent Duplicates In String II
132 - 132 Pattern
895 - Maximum Frequency Stack
84 - Largest Rectangle In Histogram

Binary Search

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
704 - Binary Search
35 - Search Insert Position
374 - Guess Number Higher Or Lower
441 - Arranging Coins
977 - Squares of a Sorted Array
367 - Valid Perfect Square
74 - Search a 2D Matrix
875 - Koko Eating Bananas
33 - Search In Rotated Sorted Array
153 - Find Minimum In Rotated Sorted Array
981 - Time Based Key Value Store
34 - Find First And Last Position of Element In Sorted Array
1898 - Maximum Number of Removable Characters
116 - Populating Next Right Pointers In Each Node
1268 - Search Suggestions System
410 - Split Array Largest Sum
4 - Median of Two Sorted Arrays

Linked List

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
206 - Reverse Linked List
21 - Merge Two Sorted Lists
234 - Palindrome Linked List
203 - Remove Linked List Elements
83 - Remove Duplicates From Sorted List
160 - Intersection of Two Linked Lists
143 - Reorder List
19 - Remove Nth Node From End of List
138 - Copy List With Random Pointer
2 - Add Two Numbers
141 - Linked List Cycle
287 - Find The Duplicate Number
24 - Swap Nodes In Pairs
148 - Sort List
86 - Partition List
61 - Rotate List
92 - Reverse Linked List II
622 - Design Circular Queue
147 - Insertion Sort List
146 - LRU Cache
23 - Merge K Sorted Lists
25 - Reverse Nodes In K Group

Trees

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
94 - Binary Tree Inorder Traversal
226 - Invert Binary Tree
104 - Maximum Depth of Binary Tree
543 - Diameter of Binary Tree
110 - Balanced Binary Tree
100 - Same Tree
572 - Subtree of Another Tree
108 - Convert Sorted Array to Binary Search Tree
617 - Merge Two Binary Trees
112 - Path Sum
606 - Construct String From Binary Tree
235 - Lowest Common Ancestor of a Binary Search Tree
102 - Binary Tree Level Order Traversal
199 - Binary Tree Right Side View
1448 - Count Good Nodes In Binary Tree
98 - Validate Binary Search Tree
230 - Kth Smallest Element In a Bst
105 - Construct Binary Tree From Preorder And Inorder Traversal
96 - Unique Binary Search Trees
129 - Sum Root to Leaf Numbers
337 - House Robber III
951 - Flip Equivalent Binary Trees
1993 - Operations On Tree
894 - All Possible Full Binary Trees
513 - Find Bottom Left Tree Value
669 - Trim a Binary Search Tree
173 - Binary Search Tree Iterator
538 - Convert Bst to Greater Tree
124 - Binary Tree Maximum Path Sum
297 - Serialize And Deserialize Binary Tree

Tries

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
208 - Implement Trie Prefix Tree
211 - Design Add And Search Words Data Structure
212 - Word Search II

Heap / Priority Queue

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
703 - Kth Largest Element In a Stream
1046 - Last Stone Weight
973 - K Closest Points to Origin
215 - Kth Largest Element In An Array
621 - Task Scheduler
355 - Design Twitter
1834 - Single Threaded Cpu
1845 - Seat Reservation Manager
1882 - Process Tasks Using Servers
1985 - Find The Kth Largest Integer In The Array
767 - Reorganize String
1405 - Longest Happy String
1094 - Car Pooling
295 - Find Median From Data Stream
1383 - Maximum Performance of a Team

Backtracking

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
78 - Subsets
39 - Combination Sum
77 - Combinations
46 - Permutations
90 - Subsets II
40 - Combination Sum II
47 - Permutations II
79 - Word Search
131 - Palindrome Partitioning
93 - Restore Ip Addresses
17 - Letter Combinations of a Phone Number
473 - Matchsticks to Square
1849 - Splitting a String Into Descending Consecutive Values
1980 - Find Unique Binary String
1239 - Maximum Length of a Concatenated String With Unique Characters
698 - Partition to K Equal Sum Subsets
51 - N Queens
52 - N Queens II

Graphs

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
463 - Island Perimeter
953 - Verifying An Alien Dictionary
200 - Number of Islands
133 - Clone Graph
695 - Max Area of Island
1905 - Count Sub Islands
417 - Pacific Atlantic Water Flow
130 - Surrounded Regions
1466 - Reorder Routes to Make All Paths Lead to The City Zero
994 - Rotting Oranges
286 - Walls And Gates
909 - Snakes And Ladders
752 - Open The Lock
802 - Find Eventual Safe States
207 - Course Schedule
210 - Course Schedule II
1958 - Check if Move Is Legal
934 - Shortest Bridge
684 - Redundant Connection
323 - Number of Connected Components In An Undirected Graph
261 - Graph Valid Tree
1553 - Minimum Number of Days to Eat N Oranges
127 - Word Ladder

Advanced Graphs

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
332 - Reconstruct Itinerary
1584 - Min Cost to Connect All Points
743 - Network Delay Time
778 - Swim In Rising Water
269 - Alien Dictionary
787 - Cheapest Flights Within K Stops

1-D Dynamic Programming

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
70 - Climbing Stairs
746 - Min Cost Climbing Stairs
198 - House Robber
213 - House Robber II
5 - Longest Palindromic Substring
647 - Palindromic Substrings
91 - Decode Ways
322 - Coin Change
152 - Maximum Product Subarray
139 - Word Break
300 - Longest Increasing Subsequence
416 - Partition Equal Subset Sum
120 - Triangle
740 - Delete And Earn
256 - Paint House
377 - Combination Sum IV
279 - Perfect Squares
1856 - Maximum Subarray Min Product
983 - Minimum Cost For Tickets
343 - Integer Break
673 - Number of Longest Increasing Subsequence
691 - Stickers to Spell Word

2-D Dynamic Programming

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
62 - Unique Paths
1143 - Longest Common Subsequence
309 - Best Time to Buy And Sell Stock With Cooldown
518 - Coin Change II
494 - Target Sum
97 - Interleaving String
877 - Stone Game
64 - Minimum Path Sum
329 - Longest Increasing Path In a Matrix
221 - Maximal Square
5782 - Maximum Alternating Subsequence Sum
115 - Distinct Subsequences
72 - Edit Distance
1220 - Count Vowels Permutation
312 - Burst Balloons
1866 - Number of Ways to Rearrange Sticks With K Sticks Visible
10 - Regular Expression Matching

Greedy

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
53 - Maximum Subarray
55 - Jump Game
45 - Jump Game II
1871 - Jump Game VII
134 - Gas Station
846 - Hand of Straights
1423 - Maximum Points You Can Obtain From Cards
1898 - Merge Triplets to Form Target Triplet
763 - Partition Labels
678 - Valid Parenthesis String
1921 - Eliminate Maximum Number of Monsters
1029 - Two City Scheduling

Intervals

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
57 - Insert Interval
56 - Merge Intervals
435 - Non Overlapping Intervals
253 - Meeting Rooms
919 - Meeting Rooms II
1288 - Remove Covered Intervals
1851 - Minimum Interval to Include Each Query

Math & Geometry

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
48 - Rotate Image
54 - Spiral Matrix
73 - Set Matrix Zeroes
202 - Happy Number
66 - Plus One
9 - Palindrome Number
263 - Ugly Number
1260 - Shift 2D Grid
13 - Roman to Integer
12 - Integer to Roman
50 - Pow(x, n)
43 - Multiply Strings
2013 - Detect Squares
1041 - Robot Bounded In Circle
6 - Zigzag Conversion
2028 - Find Missing Observations

Bit Manipulation

Problem C C++ C# GO Java JS Kotlin Python Ruby Rust Scala Swift TS
136 - Single Number
191 - Number of 1 Bits
338 - Counting Bits
190 - Reverse Bits
268 - Missing Number
371 - Sum of Two Integers
7 - Reverse Integer
67 - Add Binary

Need to update the README? Update the template instead.

About

Leetcode solutions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 22.7%
  • JavaScript 21.2%
  • Java 11.8%
  • C# 9.0%
  • Python 8.2%
  • C 5.6%
  • Other 21.5%