mirror of
https://github.com/Manoj-HV30/dsa-competitive-programming.git
synced 2026-05-16 19:35:22 +00:00
8 lines
362 B
Markdown
8 lines
362 B
Markdown
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)
|
|
|
|
|