Practice-Coding-Questions
Practice-Coding-Questions copied to clipboard
Practice set for SWE interview prep. Includes my personal solutions for Leetcode, CTCI, SPOJ, etc.
trafficstars
Practice-Coding-Questions
Personal Practice Set - Doing One a Day (sometimes) in a Variety of Languages (Mostly Python)!
Leetcode
| # | Difficulty | Problem | Solution |
|---|---|---|---|
| 1 | Easy | Two Sum | Java, Python, Ruby |
| 2 | Medium | Add Two Numbers | C |
| 3 | Medium | Longest Substring Without Repeating Characters | Python |
| 4 | Hard | Median of Two Sorted Arrays | Python |
| 5 | Medium | Longest Palindromic Substring | Python |
| 6 | Medium | Zig Zag Conversion | Java |
| 7 | Easy | Reverse Integer | Python |
| 8 | Medium | String to Integer | Ruby |
| 9 | Easy | Palindrome Number | C, Java, Python, Swift |
| 10 | Hard | Regular Expression Matching | Python |
| 11 | Medium | Container With Most Water | Python |
| 12 | Medium | Integer to Roman | Python |
| 13 | Easy | Roman to Integer | C, Python |
| 14 | Easy | Longest Common Prefix | Python |
| 15 | Medium | 3Sum | Python |
| 16 | Medium | 3Sum Closest | Python |
| 17 | Medium | Letter Combinations of a Phone Number | Python |
| 18 | Medium | 4Sum | Python |
| 19 | Medium | Remove Nth Node From End of List | Python |
| 20 | Easy | Valid Parentheses | Java, Python |
| 21 | Easy | Merge Two Sorted Lists | Java, Python |
| 22 | Medium | Generate Parentheses | Python |
| 23 | Hard | Merge k Sorted Lists | Python |
| 24 | Medium | Swap Node in Pairs | Python |
| 25 | Hard | Reverse Nodes in k-Group | Python |
| 26 | Easy | Remove Duplicates from Sorted Array | C, Python |
| 27 | Easy | Remove Element | Python |
| 28 | Easy | Implement strStr() | C, Python |
| 29 | Medium | Divide Two Integers | Python |
| 31 | Medium | Next Permutation | Python |
| 33 | Medium | Search in Rotated Sorted Array | Python |
| 34 | Medium | Find First and Last Position of Element in Sorted Array | Python |
| 35 | Easy | Search Insert Position | Go, Java, JavaScript, Scala |
| 36 | Medium | Valid Sudoku | Python |
| 38 | Easy | Count and Say | Python |
| 39 | Medium | Combination Sum | Python |
| 40 | Medium | Combination Sum II | Python |
| 42 | Hard | Trapping Rain Water | Python |
| 43 | Medium | Multiply Strings | Python |
| 44 | Hard | Wildcard Matching | Python |
| 46 | Medium | Permutations | Python |
| 47 | Medium | Permutations II | Python |
| 48 | Medium | Rotate Image | Python |
| 49 | Medium | Group Anagrams | Python |
| 50 | Medium | Pow(x, n) | Python |
| 53 | Easy | Maximum Subarray | Java |
| 54 | Medium | Spiral Matrix | Python |
| 55 | Medium | Jump Game | Python |
| 56 | Medium | Merge Intervals | Python |
| 58 | Easy | Length of Last Word | Python |
| 62 | Medium | Unique Paths | Python |
| 63 | Medium | Unique Paths II | Python |
| 64 | Medium | Minimum Path Sum | Python |
| 66 | Easy | Plus One | Python |
| 67 | Easy | Add Binary | Python |
| 69 | Easy | Sqrt() | Python |
| 70 | Easy | Climbing Stairs | C |
| 76 | Hard | Minimum Window Substring | Python |
| 78 | Medium | Subsets | Python |
| 79 | Medium | Word Search | Python |
| 83 | Easy | Remove Duplicates from Sorted List | Python |
| 84 | Hard | Largest Rectangle in Histogram | Python |
| 85 | Hard | Maximal Rectangle | Python |
| 88 | Easy | Merge Sorted Array | Python |
| 100 | Easy | Same Tree | Python |
| 101 | Easy | Symmetric Tree | Python |
| 102 | Medium | Binary Tree Level Order Traversal | Python |
| 104 | Easy | Maximum Depth of Binary Tree | Python |
| 105 | Medium | Construct Binary Tree from Preorder and Inorder Traversal | Python |
| 106 | Medium | Construct Binary Tree from Inorder and Postorder Traversal | Python |
| 107 | Easy | Binary Tree Level Order Traversal II | Python |
| 108 | Easy | Convert Sorted Array to Binary Search Tree | Python |
| 110 | Easy | Balanced Binary Tree | Python |
| 111 | Easy | Minimum Depth of Binary Tree | Python |
| 112 | Easy | Path Sum | Python |
| 118 | Easy | Pascal's Triangle | Python |
| 121 | Easy | Best Time to Buy and Sell Stock | Python |
| 122 | Easy | Best Time to Buy and Sell Stock II | Python |
| 123 | Hard | Best Time to Buy and Sell Stock III | Python |
| 125 | Easy | Valid Palindrome | Python |
| 127 | Medium | Word Ladder | Python |
| 133 | Medium | Clone Graph | Python |
| 136 | Easy | Single Number | Python |
| 137 | Medium | Single Number II | Python |
| 139 | Medium | Word Break | Python |
| 141 | Easy | Linked List Cycle | Python |
| 142 | Medium | Linked List Cycle II | Python |
| 146 | Hard | LRU Cache | Python |
| 148 | Medium | Sort List | Python |
| 153 | Medium | Find Minimum in Rotated Sorted Array | Python |
| 155 | Easy | Min Stack | Python |
| 162 | Medium | Find Peak Element | Python |
| 168 | Easy | Excel Sheet Column Title | Python |
| 171 | Easy | Excel Sheet Column Number | Python |
| 173 | Medium | Binary Search Tree Iterator | Python |
| 188 | Hard | Best Time to Buy and Sell Stock IV | Python |
| 191 | Easy | Number of 1 Bits | Python |
| 196 | Easy | Delete Duplicate Emails | SQL |
| 200 | Medium | Number of Islands | Python |
| 204 | Easy | Count Primes | Python |
| 206 | Easy | Reverse Linked List | Python |
| 207 | Medium | Course Schedule | Python |
| 208 | Medium | Implement Trie | Java, Python |
| 215 | Medium | Kth Largest Element in an Array | Python |
| 218 | Hard | The Skyline Problem | Python |
| 226 | Easy | Invert Binary Tree | Python |
| 231 | Easy | Power Of Two | Python |
| 234 | Easy | Palindrome Linked List | Python |
| 235 | Easy | Lowest Common Ancestor of a Binary Search Tree | Python |
| 236 | Medium | Lowest Common Ancestor of a Binary Tree | Python |
| 237 | Easy | Delete Node in a Linked List | Python |
| 238 | Medium | Product of Array Except Self | Python |
| 240 | Medium | Search a 2D Matrix II | Python |
| 258 | Easy | Add Digits | Python |
| 268 | Easy | Missing Number | Python |
| 273 | Hard | Integer to English Words | Python |
| 283 | Easy | Move Zeroes | Python |
| 287 | Medium | Find the Duplicate Number | Python |
| 295 | Hard | Find Median from Data Stream | Python |
| 297 | Hard | Serialize and Deserialize Binary Tree | Java |
| 301 | Hard | Remove Invalid Parentheses | Python |
| 310 | Medium | Minimum Height Trees | Python |
| 341 | Medium | Flatten Nested List Iterator | Python |
| 344 | Easy | Reverse String | Python |
| 388 | Medium | Longest Absolute File Path | Python |
| 389 | Easy | Find the Difference | Python |
| 461 | Easy | Hamming Distance | Python |
| 495 | Medium | Teemo Attacking | Python |
| 535 | Medium | Encode and Decode TinyURL | Python |
| 733 | Easy | Flood Fill | Python |
| 771 | Easy | Jewels and Stones | Python |
| 1114 | Easy | Print in Order | Python |
SPOJ
| # | Difficulty | Problem | Solution |
|---|---|---|---|
| 1 | Easy | Life, the Universe, and Everything | C |
| 2 | |||
| 3 |
Hackerrank
30 Days of Code Challenge
| Day | Difficulty | Problem | Solution |
|---|---|---|---|
| 0 | Easy | Hello, World. | Java |
| 1 | Easy | Data Types | Java |
| 2 | Easy | Operators | Java |
| 3 | Easy | Conditional Statements | Python |
| 4 | Easy | Class vs Instance | Python |
| 5 | Easy | Loops | Python |
| 6 | Easy | Let's Review | Python |
| 7 | Easy | Arrays | Python |
| 8 | Easy | Dictionaries and Maps | Python |
| 9 | Easy | Recursion | Python |
| 10 | Easy | Binary Number | Python |
| 11 | Easy | 2D Arrays | Python |
| 12 | Easy | Inheritance | Python |
| 13 | Easy | Abstract Classes | Python |
| 14 | Easy | Scope | Python |
| 15 | Easy | Linked List | Python |
| 16 | Easy | Exceptions - String to Integer | Python |
| 17 | Easy | More Exceptions | Python |
| 18 | Easy | Queues and Stacks | Python |
| 19 | Easy | Interfaces | Java |
| 20 | Easy | Sorting | Python |
| 21 | Easy | Generics | Java |
| 22 | Easy | Binary Search Trees | Java |
| 23 | Easy | BST Level-Order Traversal | Python |
| 24 | Easy | More Linked Lists | Python |
| 25 | Medium | Running Time and Complexity | Python |
| 26 | Easy | Nested Logic | Python |
| 27 | Easy | Testing | Python |
| 28 | Medium | RegEx, Patterns, and Intro to Databases | Python |
| 29 | Medium | Bitwise AND | Python |
CTCI
Cracking the Coding Interview 6th Edition Python Solutions
| # | Difficulty | Problem | Solution |
|---|---|---|---|
| 1.1 | Is Unique | Python | |
| 1.2 | Check Permutation | Python | |
| 1.3 | URLify | Python | |
| 1.4 | Palindrome Permutation | Python | |
| 1.5 | One Away | Python | |
| 1.6 | String Compression | Python | |
| 1.7 | Rotate Matrix | Python | |
| 1.8 | Zero Matrix | Python | |
| 1.9 | String Rotation | Python | |
| 2.1 | Remove Dups | Python | |
| 2.2 | Return Kth to Last | Python | |
| 2.3 | Delete Middle Node | Python | |
| 2.4 | Partition | Python | |
| 2.5 | Sum Lists | Python | |
| 2.6 | Palindrome | Python | |
| 2.7 | Intersection | Python | |
| 2.8 | Loop Detection | Python | |
| 3.1 | Three in One | Python | |
| 3.2 | Stack Min | Python | |
| 3.3 | Stack of Plates | Python | |
| 4.1 | Route Between Nodes | Python | |
| 4.2 | Minimal Tree | Python | |
| 4.3 | List of Depths | Python | |
| 4.4 | Check Balanced | Python | |
| 4.5 | Validate BST | Python | |
| 4.6 | Successor | Python | |
| 4.7 | Build Order | Python | |
| 4.8 | First Common Ancestor | Python | |
| 4.9 | BST Sequences | Python | |
| 4.10 | Check Subtree | Python | |
| 4.11 | Random Node | Python | |
| 4.12 | Paths With Sum | Python | |
| 5.1 | Insertion | Coming Soon | |
| 8.1 | Triple Step | Python | |
| 8.2 | Robot in a Grid | Python | |
| 8.3 | Magic Index | Python | |
| 8.4 | Power Set | Python | |
| 8.5 | Recursive Multiply | Python | |
| 8.6 | Towers of Hanoi | ||
| 8.7 | Permutations Without Dups | Python | |
| 8.8 | Permutations With Dups | Python | |
| 17.1 | Add Without Plus | Python |
Google Foobar Challenge
| # | Level | Problem | Solution |
|---|---|---|---|
| 1 | 1 | Solar Doomsday | Java |
| 2 | 2 | Gearing Up For Destruction | Python |
| 3 | 2 | Lovely Lucky Lambs | Python |