Files
dsa-competitive-programming/leetcode/lc15/notes.md
T
2026-02-11 14:56:22 +05:30

362 B

The intuition in this problem is we first sort the entire list and then fix i on first index and j at i+1 and k at last index and then compute total ,if(total>0) then since it is sorted, we need to bring total down so we do k-- and if total<0 then j++

To avoid recomputations for same j, we do j++ until nums[j]!=nums[j-1]

TC : o(nlogn) + o(n*n); SC : o(1)