Complete resources to practice problems solving and prepare for coding interviews. This repo shows my solutions in C# and Python for real interview questions taken from different sites (the origin link to the question is always in the description). Currently, we have a few completed solutions focused on Array, String, Linked List, Stack, Queue, and other data structures.
Please feel free to reference and ⭐ to support this repo, thank you!
- Array
- String
- Linked List
- Hash Table
- Stack
- Queue
- Tree
- Graph
- Bit manipulation
- Sorting
- Compression Algorithms
- Ciphers
- Math
- Dynamic Programming
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Determine if String Halves Are Alike | Easy | O(n) | O(1) | |
Determine if Two Strings Are Close | Medium | O(n) | O(n) | |
Sort Characters By Frequency | Medium | O(n) | O(n) | |
Is Unique | Easy | O(n) | O(1) | |
Check Permutation | Easy | O(n) | O(1) | |
URLify | Easy | O(n) | O(1) | |
Palindrome Permutation | Medium | O(n) | O(1) | |
One Way | Medium | O(n) | O(n) | |
String Compression | Medium | O(n) | O(1) | |
Word Pattern | Easy | O(n) | O(n) | |
Detect Capital | Easy | O(n) | O(1) | |
Lexicographically Smallest Equivalent String | Medium | O(n) | O(n) | |
Flip String to Monotone Increasing | Medium | O(n) | O(1) | |
Permutation in String | Medium | O(l_1+(l_2-l_1)) | O(1) | |
Find the Index of the First Occurrence in a String | Easy | O(n) | O(1) | |
Custom Sort String | Easy | O(n) | O(n) | |
String to Integer (atoi) | Medium | O(n) | O(1) | |
Zigzag Conversion | Medium | O(n) | O(n) | |
Find the Duplicate Number | Medium | O(n log_2 n) | O(1) | |
Length of Last Word | Easy | O(n) | O(1) | |
Count and Say | Medium | O(n^2) | O(n) | |
Make The String Great | Easy | O(n) | O(1) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Middle of the Linked List | Easy | O(n) | O(1) | |
Odd Even Linked List | Medium | O(n) | O(1) | |
Intersection of Two Linked Lists | Easy | O(n) | O(1) | |
Partition List | Medium | O(n) | O(1) | |
Swap Nodes in Pairs | Medium | O(n) | O(1) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Letter Combinations of a Phone Number | Medium | O(n) | O(1) | |
Minimum Rounds to Complete All Tasks | Medium | O(n) | O(n) | |
Max Points on a Line | Hard | O(n^2) | O(n) | |
Naming a Company | Hard | O(n) | O(n) | |
Isomorphic Strings | Easy | O(n) | O(n) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Find the Difference | Easy | O(n+m) | O(1) | |
Reverse Bits | Easy | O(1) | O(1) | |
Add Binary | Easy | O(1) | O(1) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
IPO | Hard | O(n*log(n)) | O(n) | |
Minimize Deviation in Array | Hard | O(nlog(n)) | O(n) | |
Total Cost to Hire K Workers | Medium | O((k+2n)*log(2n)) | O(log 2n) | |
Shortest Path to Get All Keys | Hard | O(m*n) | O(m*n) | |
Sliding Window Maximum | Hard | O(n) | O(k) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Evaluate Reverse Polish Notation | Medium | O(n) | O(n) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Majority Element | Medium | O(n/2) | O(1) | |
Sort Colors | Medium | O(n) | O(1) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Symmetric Tree | Easy | O(log n) | O(1) | |
Range Sum of BST | Easy | O(n) | O(1) | |
Leaf-Similar Trees | Easy | O(n) | O(n) | |
Binary Tree Preorder Traversal | Easy | O(n) | O(n) | |
Max Difference Between Node and Ancestor | Medium | O(n) | O(1) | |
Max Product of Splitted Binary Tree | Medium | O(n) | O(n) | |
Binary Tree Maximum Path Sum | Hard | O(n) | O(1) | |
Find if Path Exists in Graph | Easy | O(V+E) | O(V) | |
All Paths From Source to Target | Medium | O(n) | O(n) | |
Same Tree | Easy | O(nlogn) | O(1) | |
Minimum Time to Collect All Apples in a Tree | Medium | O(n) | O(n) | |
Number of Nodes in the Sub-Tree With the Same Label | Medium | O(n) | O(n) | |
Longest Path With Different Adjacent Characters | Hard | O(n) | O(n) | |
Number of Good Paths | Hard | O(nlogn) | O(n) | |
Minimum Fuel Cost to Report to the Capital | Medium | O(n) | O(n) | |
Construct Quad Tree | Medium | O(N^2) | O(N^2) | |
Minimum Absolute Difference in BST | Easy | O(N) | O(1) | |
Maximum Level Sum of a Binary Tree | Medium | O(N) | O(N) | |
Path Sum | Easy | O(log N) | O(1) | |
Balanced Binary Tree | Easy | O(log N) | O(1) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Find if Path Exists in Graph | Easy | O(V+E) | O(V) | |
KeysAndRooms | Medium | O(n) | O(n) | |
Maximal Network Rank | Medium | O(V+E) | O(N^2logN) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
LZ77 | Medium | O(n) | O(n) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Integer to Roman | Medium | O(n) | O(1) | |
Climbing Stairs | Medium | O(n) | O(1) | |
Domino and Tromino Tiling | Medium | O(n) | O(1) | |
Best Time to Buy and Sell Stock with Cooldown | Medium | O(n) | O(1) | |
Count Odd Numbers in an Interval Range | Easy | O(1) | O(1) | |
Divide Two Integers | Medium | O(log n) | O(1) |
Title | Solution | Difficulty | Time | Space |
---|---|---|---|---|
Longest Common Subsequence | Medium | O(m*n) | O(m*n) | |
As Far from Land as Possible | Medium | O(m*n) | O(m*n) | |
Edit Distance | Hard | O(mn) | O(n) | |
Generate Parentheses | Medium | O(n) | O(n) | |
Combination Sum II | Medium | O(n) | O(n) |
LeetCode Online is a website containing many algorithm questions. Most of them are real interview questions of Google, Facebook, LinkedIn, Apple, etc.