Key insight: treat each '_' as L or R, simulate both extremes, and take max absolute distance. This gives the furthest reachable point. Clean, smart, and efficient!
#LeetCode #Cpp #Algorithms #DSA
Key insight: treat each '_' as L or R, simulate both extremes, and take max absolute distance. This gives the furthest reachable point. Clean, smart, and efficient!
#LeetCode #Cpp #Algorithms #DSA
#LeetCodeRewind #DevLife #CodingJourney #DSA #Programming
#LeetCodeRewind #DevLife #CodingJourney #DSA #Programming
My approach: iterate through the string, count spaces until we hit k, then return substr(0, idx) at that position.
Simple logic: k words = k-1 spaces 🧠
TC: O(n) | SC: O(1)
#LeetCode #CPP #CodingLife
My approach: iterate through the string, count spaces until we hit k, then return substr(0, idx) at that position.
Simple logic: k words = k-1 spaces 🧠
TC: O(n) | SC: O(1)
#LeetCode #CPP #CodingLife
Use a max heap to repeatedly pick the largest pile and reduce it to the floor(sqrt).
O(n + k log n) time, O(n) space.
Simple but effective!
#Algorithms #Heap #Programming
Use a max heap to repeatedly pick the largest pile and reduce it to the floor(sqrt).
O(n + k log n) time, O(n) space.
Simple but effective!
#Algorithms #Heap #Programming
The trick? Distinguishing leaves from internal nodes:
- Leaf: !left && !right ❌🍃
- Internal: left && right ✅🌿
Pass a flag during recursion to track left children. Got 100% runtime! 🚀
#LeetCode #Algorithms #CodingInterview
The trick? Distinguishing leaves from internal nodes:
- Leaf: !left && !right ❌🍃
- Internal: left && right ✅🌿
Pass a flag during recursion to track left children. Got 100% runtime! 🚀
#LeetCode #Algorithms #CodingInterview
VS Code kept warning "too many git commits" – ignored it for months.
Finally checked: 50,000+ commits in ~ 😂
Removed the .git folder & peace restored
Pro tip: NEVER git init in $HOME #git #programming #webdev #developers
VS Code kept warning "too many git commits" – ignored it for months.
Finally checked: 50,000+ commits in ~ 😂
Removed the .git folder & peace restored
Pro tip: NEVER git init in $HOME #git #programming #webdev #developers
Constraints give a clear idea of the time complexity you should think about.
If operations are within ~10⁸, you already know which approach can work.
Constraints give a clear idea of the time complexity you should think about.
If operations are within ~10⁸, you already know which approach can work.
Added a proper first page to it.
Go check it out
github.com/vagueman57
Added a proper first page to it.
Go check it out
github.com/vagueman57
I’ve been learning software development for some time.
From now on, I’ll start posting here and try to be regular.
I’ll share what I learn while building projects.
I’ve been learning software development for some time.
From now on, I’ll start posting here and try to be regular.
I’ll share what I learn while building projects.