Hello there! π This is where I chronicle my coding grind, breaking down each problem I tackle on LeetCode. Follow along to see my thought processes, the challenges I've encountered, and the strategies that have worked for me!
- Total Problems Solved: 4
- Easy Problems: 4
- Medium Problems: 0
- Hard Problems: 0
Best playlist to code: https://open.spotify.com/playlist/5LodgsmFfRYAojTwEZ9ulR?si=bcf8faee8e4b4f2a
1. Two Sum
- Approach: Simple approach by just going through all element of array
- Challenges: No challenges
- Time Complexity: 0(n^2)
- Space Complexity: 0(1)
- Approach: Compare original string to reversed one
- Challenges: No challenges
- Time Complexity: 0(n)
- Space Complexity: 0(n)
3. Roman To Int
- Approach: The problem here is that we can meet next values that can be combination of prev+next, so what we do here is basically, when we see a number that is less than the next number, we substract first digit and then add second (like IV: substract 1 from total and add 5 results in 4)
- Challenges: Coming up with the optimized version, originally just hardcoded values (which is not cool lol)
- Time Complexity: 0(n)
- Space Complexity: 0(1)
- Approach: Sort array to make sure all common strings will be next to each other, then just compare first and last element letters and see when they don't equal to each other, on that point we found substring
- Challenges: Come up with sorting
- Time Complexity: O(n log n)
- Space Complexity: 0(1)
- Approach: Create a map of valid parentheses and basically use stack to solve, go through each char of string and if it's opening parentheses, add to stack, otherwise pop and check if it's valid, also make sure that stack is empty in the end
- Challenges: No challenges
- Time Complexity: O(n)
- Space Complexity: 0(n)
- Approach: Create new list with head node, then just go through lists (while they both exists) and compare which number is less and add this number to head (don't forget to advance pointer on original lists, finally check if any list still has items and add all of that items to the end)
- Challenges: Refresh mind on linked lists (lol)
- Time Complexity: O(m + n)
- Space Complexity: 0(1)
- Approach: Make set from array and then just return length of this array, also fill the original array with values to match the problem description
- Challenges: Understand the problem (lol x2)
- Time Complexity: O(n)
- Space Complexity: 0(n)
- Approach: Brief description of your approach.
- Challenges: What challenges did you face and how did you overcome them?
- Time Complexity: Your analysis.
- Space Complexity: Your analysis.
... [Repeat for other medium problems]
- Approach: Brief description of your approach.
- Challenges: What challenges did you face and how did you overcome them?
- Time Complexity: Your analysis.
- Space Complexity: Your analysis.
... [Repeat for other hard problems]
- 08/28/23: Started the grind