Kr_Shubham's blog

By Kr_Shubham, history, 8 months ago, In English

Find the number of ways to partition array into segments such that sum of each segments is greater than 0,

Note- Concatenating the segments should result into full array.

Constraints: 1<=N<=10^5 1<=a[I]<=10^9 Example:

Input1: N=3, a[]={-1,-3,7}

Output: 1. (Complete array as one Segment)

Thanks

PS. This is not part of any running Contest.

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By Kr_Shubham, 3 years ago, In English

This code is taking around 1300 ms. (size of set shouldn't exceed more than 1 at any time, Since I am inserting same element every time)

Spoiler

But , After commenting the s.erase(), it just took 15 ms.

Spoiler

Can anyone please explain the reason behind this? Thanks in advance :)

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it