Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/calvinjmin/interview_questions

Personal Solutions to common Leet Code Questions
https://github.com/calvinjmin/interview_questions

algorithm java leetcode python

Last synced: 3 days ago
JSON representation

Personal Solutions to common Leet Code Questions

Awesome Lists containing this project

README

        

# Interview Questions
The purpose of this repo is to keep track of key algorithms/solutions for common Leetcode questions. Furthermore, there will be solutions in multiple languages to show the versatility of my coding abilities.
## Languages
### C++ Files
#### Array

| File Name | Description |
|---|---|
| [best-time-to-buy-and-sell-stock-121.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Array/best-time-to-buy-and-sell-stock-121.cpp) | Sliding Window - [Leetcode 121](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/) |
| [gas-station-.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Array/gas-station-.cpp) | Math Logic with Array Trackers - [Leetcode 134](https://leetcode.com/problems/gas-station/description/) |
| [kids-with-the-greatest-number-of-candies-1431.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Array/kids-with-the-greatest-number-of-candies-1431.cpp) | Array Manipulation with Max Value - [Leetcode 1431](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/) |
| [meeting-rooms-252.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Array/meeting-rooms-252.cpp) | Basic 2D Vector Sorting - [Leetcode 252](https://leetcode.com/problems/meeting-rooms/description/) |
| [minimum-time-difference-539.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Array/minimum-time-difference-539.cpp) | Sorting and Converting String - [Leetcode 539](https://leetcode.com/problems/minimum-time-difference/description/) |

#### Two_Pointer

| File Name | Description |
|---|---|
| [containter-with-most-water-11.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Two_Pointer/containter-with-most-water-11.cpp) | Out to In Two Pointer - [Leetcode 11](https://leetcode.com/problems/container-with-most-water/description/) |
| [is-subsequence-392.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Two_Pointer/is-subsequence-392.cpp) | Two Pointer with Basic Tracker - [Leetcode 392](https://leetcode.com/problems/is-subsequence/description/) |
| [three-sum-15.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Two_Pointer/three-sum-15.cpp) | Two Pointer with Set Tracker - [Leetcode 15](https://leetcode.com/problems/3sum/) |
| [trapping-rain-water-42.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Two_Pointer/trapping-rain-water-42.cpp) | Two Pointer with Max Wall - [Leetcode 42](https://leetcode.com/problems/trapping-rain-water/description/) |

#### Sliding_Window

| File Name | Description |
|---|---|
| [find-all-anagrams-in-a-string-438.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Sliding_Window/find-all-anagrams-in-a-string-438.cpp) | Prefix Window - [Leetcode 438](https://leetcode.com/problems/find-all-anagrams-in-a-string/description/) |
| [longest-substring-without-repeating-characters-3.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Sliding_Window/longest-substring-without-repeating-characters-3.cpp) | Set with Sliding Window - [Leetcode 3](https://leetcode.com/problems/longest-substring-without-repeating-characters/) |
| [maximum-number-of-vowels-in-a-substring-of-given-length-1456.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Sliding_Window/maximum-number-of-vowels-in-a-substring-of-given-length-1456.cpp) | O(1) Vector Lookup with Sliding Window - [Leetcode 1456](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length) |
| [minimum-size-subarray-sum-208.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Sliding_Window/minimum-size-subarray-sum-208.cpp) | Sliding Window w/ Running Counter - [Leetcode 208](https://leetcode.com/problems/minimum-size-subarray-sum/description/) |

#### Backtracking

| File Name | Description |
|---|---|
| [letter-combinations-of-a-phone-number-17.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Backtracking/letter-combinations-of-a-phone-number-17.cpp) | Iteration with Backtracking - [Leetcode 17](https://leetcode.com/problems/letter-combinations-of-a-phone-number/description) |
| [pemutations-II-47.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Backtracking/pemutations-II-47.cpp) | Permutations w/ all possible combinations - [Leetcode 47](https://leetcode.com/problems/permutations-ii/) |
| [word-search-79.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Backtracking/word-search-79.cpp) | DFS Backtracking on a Grid - [Leetcode 79](https://leetcode.com/problems/word-search/description/) |

#### Greedy

| File Name | Description |
|---|---|
| [ipo-502.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Greedy/ipo-502.cpp) | Maximize Profits with Priority Queue - [Leetcode 502](https://leetcode.com/problems/ipo/description/) |
| [jump-game-55.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Greedy/jump-game-55.cpp) | Greedy Choice - [Leetcode 55](https://leetcode.com/problems/jump-game/description/) |
| [jump-game-II-45.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Greedy/jump-game-II-45.cpp) | Greedy Choice w/ Tracker - [Leetcode 45](https://leetcode.com/problems/jump-game-ii/description/) |
| [largest-number-179.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Greedy/largest-number-179.cpp) | Greedy Choice with sorting based on string concatenation - [Leetcode 179](https://leetcode.com/problems/largest-number/description/) |
| [optimal-partition-of-string-2405.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Greedy/optimal-partition-of-string-2405.cpp) | Take longest substring until there is a duplicate - [Leetcode 2405](https://leetcode.com/problems/optimal-partition-of-string/description/) |

#### Dynamic_Programming

| File Name | Description |
|---|---|
| [coin-change-322.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/coin-change-322.cpp) | Bottom Up DP - [Leetcode 322](https://leetcode.com/problems/coin-change/description/) |
| [decode-ways-91.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/decode-ways-91.cpp) | Iterative Dynamic Programming - [Leetcode 91](https://leetcode.com/problems/decode-ways/description) |
| [different-ways-to-add-parentheses-241.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/different-ways-to-add-parentheses-241.cpp) | Breaking expressions into two with DP - [Leetcode 241](https://leetcode.com/problems/different-ways-to-add-parentheses/description) |
| [extra-characters-in-a-string-2707.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/extra-characters-in-a-string-2707.cpp) | Bottom Up Method w/ Substring - [Leetcode 2707](https://leetcode.com/problems/extra-characters-in-a-string/description/) |
| [house-robber-198.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/house-robber-198.cpp) | Basic DP Question - [Leetcode 198](https://leetcode.com/problems/house-robber/description/) |
| [house-robber-II-213.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/house-robber-II-213.cpp) | Twist with Tracking in Circular Array - [Leetcode 213](https://leetcode.com/problems/house-robber-ii/description/) |
| [longest-palindromic-substring-5.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/longest-palindromic-substring-5.cpp) | Two Pointer with Dynamic Programming - [Leetcode 5](https://leetcode.com/problems/different-ways-to-add-parentheses) |
| [minimum-path-sum-64.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/minimum-path-sum-64.cpp) | 2D Matrix Dynamic Programming - [Leetcode 64](https://leetcode.com/problems/minimum-path-sum/) |
| [palindromic-substrings-647.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Dynamic_Programming/palindromic-substrings-647.cpp) | 2D DP with Two Pointer Logic - [Leetcode 647](https://leetcode.com/problems/palindromic-substrings/description/) |

#### Graph

| File Name | Description |
|---|---|
| [number-of-closed-islands-1254.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Graph/number-of-closed-islands-1254.cpp) | BFS on 2D Matrix with a Twist - [Leetcode 1254](https://leetcode.com/problems/number-of-closed-islands/) |
| [number-of-islands-200.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Graph/number-of-islands-200.cpp) | BFS on 2D Matrix - [Leetcode 200](https://leetcode.com/problems/number-of-islands/) |

#### Math

| File Name | Description |
|---|---|
| [armstrong-number-1134.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Math/armstrong-number-1134.cpp) | Mod and Power - [Leetcode 1134](https://leetcode.com/problems/armstrong-number) |
| [reverse-integer-7.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Math/reverse-integer-7.cpp) | Basic Math Manipulation - [Leetcode 7](https://leetcode.com/problems/reverse-integer/description/?) |
| [the-kth-factor-of-n-1492.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Math/the-kth-factor-of-n-1492.cpp) | Principles of being a factor - [Leetcode 1492](https://leetcode.com/problems/the-kth-factor-of-n/description/) |

#### Hash_Table

| File Name | Description |
|---|---|
| [determine-if-two-strings-are-close-1657.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/determine-if-two-strings-are-close-1657.cpp) | Set with Freq Map Equality - [Leetcode 1657](https://leetcode.com/problems/determine-if-two-strings-are-close) |
| [group-anagrams-49.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/group-anagrams-49.cpp) | Key Generation using Freq Map - [Leetcode 49](https://leetcode.com/problems/group-anagrams) |
| [largest-unique-number-1133.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/largest-unique-number-1133.cpp) | Reverse Iterator with Map - [Leetcode 1133](https://leetcode.com/problems/largest-unique-number) |
| [longest-consecutive-sequence-128.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/longest-consecutive-sequence-128.cpp) | Elevated TwoSum - [Leetcode 128](https://leetcode.com/problems/longest-consecutive-sequence/) |
| [minimum-number-of-keypresses-2268.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/minimum-number-of-keypresses-2268.cpp) | Frequency Map w/ Basic Sorting - [Leetcode 2268](https://leetcode.com/problems/minimum-number-of-keypresses/description/) |
| [two-sum-1.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/two-sum-1.cpp) | Hash Table to hold complement - [Leetcode 1](https://leetcode.com/problems/two-sum/) |
| [uncommon-words-from-two-sentences-884.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Hash_Table/uncommon-words-from-two-sentences-884.cpp) | Using String Stream to Split w/ Hash Table - [Leetcode 884](https://leetcode.com/problems/uncommon-words-from-two-sentences/description/) |

#### Heap

| File Name | Description |
|---|---|
| [kth-largest-element-in-array-215.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Heap/kth-largest-element-in-array-215.cpp) | Min Heap O(n) Loop - [Leetcode 215](https://leetcode.com/problems/kth-largest-element-in-an-array/description/) |
| [meeting-rooms-ii-253.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Heap/meeting-rooms-ii-253.cpp) | Using Heap with Basic Logic - [Leetcode 253](https://leetcode.com/problems/meeting-rooms-ii/description) |

#### Trees

| File Name | Description |
|---|---|
| [binary-tree-level-order-traversal-102.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Trees/binary-tree-level-order-traversal-102.cpp) | BFS on Binary Tree - [Leetcode 102](https://leetcode.com/problems/binary-tree-level-order-traversal/description) |
| [binary-tree-right-side-view-199.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Trees/binary-tree-right-side-view-199.cpp) | Level Order Traversal with a Twist - [Leetcode 199](https://leetcode.com/problems/binary-tree-right-side-view/description/) |
| [sum-root-to-leaf-numbers-129.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Trees/sum-root-to-leaf-numbers-129.cpp) | Basic Path DFS - [Leetcode 129](https://leetcode.com/problems/sum-root-to-leaf-numbers/) |
| [treeNode.h](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Trees/treeNode.h) | Helper TreeNode Struct |

#### Prefix_Tree

| File Name | Description |
|---|---|
| [lexicographical-numbers-386.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Prefix_Tree/lexicographical-numbers-386.cpp) | Basics of a Prefix Tree - [Leetcode 386](https://leetcode.com/problems/lexicographical-numbers) |

#### Sets

| File Name | Description |
|---|---|
| [my-calendar-1-729.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Sets/my-calendar-1-729.cpp) | Lower Bound Set Method - [Leetcode 729](https://leetcode.com/problems/my-calendar-i/description/) |
| [rank-transform-of-an-array-1331.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Sets/rank-transform-of-an-array-1331.cpp) | Auto Sort with Set - [Leetcode 1331](https://leetcode.com/problems/rank-transform-of-an-array/) |

#### Stacks

| File Name | Description |
|---|---|
| [maximum-width-ramp-962.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Stacks/maximum-width-ramp-962.cpp) | Using Sorted Stack and Traverse - [Leetcode 962](https://leetcode.com/problems/maximum-width-ramp/description/) |
| [minimum-remove-to-make-valid-parentheses-1249.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Stacks/minimum-remove-to-make-valid-parentheses-1249.cpp) | Valid Parentheses Sister Question - [Leetcode 1249](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses) |

#### Binary_Search

| File Name | Description |
|---|---|
| [find-first-and-last-position-of-element-in-sorted-array-34.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Binary_Search/find-first-and-last-position-of-element-in-sorted-array-34.cpp) | Modified Binary Search to look left and right - [Leetcode 34](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/) |
| [koko-eating-bananas-875.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Binary_Search/koko-eating-bananas-875.cpp) | Binary Search to Find Rate - [Leetcode 875](https://leetcode.com/problems/koko-eating-bananas/) |
| [search-insert-position-35.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Binary_Search/search-insert-position-35.cpp) | Basics of Binary Search - [Leetcode 35](https://leetcode.com/problems/search-insert-position/description) |

#### Matrix

| File Name | Description |
|---|---|
| [game-of-life-289.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Matrix/game-of-life-289.cpp) | In Place Solution with Matrix Manipulation - [Leetcode 289](https://leetcode.com/problems/game-of-life/) |

#### Linked_Lists

| File Name | Description |
|---|---|
| [add-two-numbers-2.cpp](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Linked_Lists/add-two-numbers-2.cpp) | Tracking Two Linked Lists - [Leetcode 2](https://leetcode.com/problems/add-two-numbers/description/) |
| [listNode.h](https://github.com/Calvinjmin/Interview_Questions/blob/main/C%2B%2B/Linked_Lists/listNode.h) | Helper ListNode Struct |

### Python Files

#### Backtracking

| File Name | Description |
|---|---|
| [generate-parentheses-22.py](https://github.com/Calvinjmin/Interview_Questions/blob/main/Python/Backtracking/generate-parentheses-22.py) | Basic Backtracking - [Leetcode 22](https://leetcode.com/problems/generate-parentheses/description/) |

#### Greedy

| File Name | Description |
|---|---|
| [jump-game-55.py](https://github.com/Calvinjmin/Interview_Questions/blob/main/Python/Greedy/jump-game-55.py) | Max Jump as Greedy Choice - [Leetcode 55](https://leetcode.com/problems/jump-game/) |

#### Dynamic_Programming

| File Name | Description |
|---|---|
| [house-robber-198.py](https://github.com/Calvinjmin/Interview_Questions/blob/main/Python/Dynamic_Programming/house-robber-198.py) | Bottom Up DP - [Leetcode 198](https://leetcode.com/problems/house-robber/) |

---
### Resources
Link to HackerRank - [Hackerank](https://www.hackerrank.com/)

Link to Leetcode - [Leetcode](https://leetcode.com/)

Calvin Min | 2024