Scan From Both Ends: How One Line Took My Divide and Conquer From TLE to AC

My solution to Vlad, Misha and Two Arrays was correct and still got TLE on test 14. The fix was to check the split candidates in the order l, r, l+1, r-1, … instead of left to right. Here is why that one change turns O(n²) into O(n log n).

September 26, 2026 · 8 min · Priyanshu Debnath

Bin Packing — Why It's Hard, How to Approximate It, and When It Isn't Hard At All

A full pass through bin packing — the formal problem, why the decision version is NP-complete (and why the optimization version is strongly so), every classical approximation algorithm with its proven bound, the special cases that collapse back to polynomial time, and the backtracking/bitmask-DP techniques you’d actually use to solve small instances in a contest.

July 7, 2026 · 30 min · Priyanshu Debnath