# LC6504: Merge Overlapping Calendar Events > Interview note — practice with [the Linkjob AI app](https://www.linkjob.ai/). ## Problem sketch Sort by start; fold intervals when overlap. ## Approach 1. Clarify constraints and edge cases for merge. 2. Start from a correct but slow baseline, then tighten hot paths. 3. Track invariants that survive each transition. ## Complexity - Time: typically O(n log n) or O(n·k) depending on input shape. - Space: O(n) for tables / stacks unless streaming. ## Pitfalls - Off-by-one on window boundaries. - Forgetting to reset state after early exits. - Integer overflow when accumulating scores. ## Checklist before coding - [ ] Examples traced by hand - [ ] Empty / single-element inputs - [ ] Duplicate values / ties Prep aid: [the Linkjob AI app](https://www.linkjob.ai/).