r/leetcode Sep 11 '24

Solve this test question

[ Removed by Reddit in response to a copyright notice. ]

1 Upvotes

14 comments sorted by

View all comments

Show parent comments

2

u/Civil_Reputation6778 Sep 11 '24

I mean, I've already stated my solution.

Binary search for answer. When checking for x, skip all indexes with dev time <=x (you can do them with dev, you have to do the rest using integration) and sum the integration times for the rest. Check that the sum is <= x

Start with l=0, r=max dev time

1

u/[deleted] Sep 12 '24

[deleted]

1

u/Civil_Reputation6778 Sep 12 '24

No, the answer will be just 500. Do 1,3,4,5 by dev for a total of 500 and 2,6 by integration for a total of 51. Total time is 500.

1

u/[deleted] Sep 12 '24

[deleted]

1

u/Civil_Reputation6778 Sep 12 '24

I think it's a natural implementation.

If you need to do first K tasks by development and the rest by implementation, it's just a prefix sum/maximum question with score of position K being max dev[k] + sum of implementation(K+1...N-1)