This content originally appeared on DEV Community and was authored by Sameer Chawla
🧠LeetCode #56 (Merge Intervals) — Needed a Few Tries to Crack It
It took me over 2 hours and 3 failed attempts to solve [LeetCode 56: Merge Intervals].
Why?
Because sometimes the problem description and examples just aren’t enough to guide you — and that’s part of the challenge.
Some tricky cases like:
[[1,4],[2,3]]
[[1,4],[0,4]]
kept failing.
I assumed the intervals were always in sorted order — they weren’t.
Then I peeked at the solution and saw:
sort(intervals.begin(), intervals.end());
That one line changed everything.
I paused, dug into how 2D sorting works in C++, and that helped unlock the logic.
đź’ˇ What I Learned:
âś… How sorting works for 2D vectors
🗣️ Reading discussions and others’ code can speed up learning
✍️ Writing it by hand helped reinforce the logic
📸 Sharing my handwritten notes and final accepted solution in C++:
If you're just starting out too — remember: it's okay to take time. The goal is to learn.
🏷 Hashtags
LearnInPublic #Cplusplus #LeetCode #ProblemSolving #BeginnerDev #CodingJourney #DeveloperJourney #DSA #Cpp #Debugging #LeetCodeSolutions #ProblemSolvingSkills
This content originally appeared on DEV Community and was authored by Sameer Chawla

Sameer Chawla | Sciencx (2025-06-11T17:19:15+00:00) 🧠LeetCode #56 (Merge Intervals) — Needed a Few Tries to Crack It. Retrieved from https://www.scien.cx/2025/06/11/%f0%9f%a7%a0-leetcode-56-merge-intervals-needed-a-few-tries-to-crack-it/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.