Pleeeeease tell me what is wrong in this solution

zco

#1

Problem link- Bookshelves

The link to my solution- greedy strategy

Please tell me a counter case which would fail in my solution. Thanks a lot.


#2

Here-

Input
5 1 3 5 2 14 1 7 2 3 10 4
Your Output
21
Expected Output
19

We can get a lower output easily. Exchange 14 in upper shelf with 2 in lower shelf. Now upper shelf has elementts 3,5,2,2,1 - max =5. Skew =19.


#3

Ok, will see. :smiley: . BTW, what TC’s is it failing? All, some , ones with large data?


#4

Thanks a lot. I am soooo stupid. I should leave CP.


#5

How did I miss such an obvious case??


#6

Dude, you need to chill. Just thinking too much, on and on and on. Focus on one thing at a time and get it sorted.


#7

Thanks @vijju123