TheRedDevil18's blog

By TheRedDevil18, history, 5 weeks ago,

I am getting WA for Test Set 2.

I looked at other people's solutions and also generated some random cases on both the correct and my solution, but both are giving the same answer.

Can anyone tell where I am getting it wrong?

My code

• +8

 » 5 weeks ago, # |   +8 Try this: 1 2 99899 99 Output should be 3. Final array: 99899 99900
•  » » 5 weeks ago, # ^ |   +8 Thanks for the help. I got it.
•  » » 5 weeks ago, # ^ |   +8 I have got this case right. Also every other case i can imagine of. Still WA on 2nd test set. I did it using long long as the data type. Could that be a problem?
•  » » » 5 weeks ago, # ^ |   0 I also overflowed. Since the minimal number that is larger than the last can be one digit longer, numbers can be up to 10^n = 10^100, far exceeding long long. There's a lot of ways to get around this like using strings.
•  » » » » 5 weeks ago, # ^ |   +5 The numbers can only go till 10^20 or 10^21 , in the case where all the given 100 elements are 10^9
•  » » » » » 5 weeks ago, # ^ |   +8 If the list of n=100 numbers is 199, 198, ... 100, the optimal solution is 199, 1980, 19700, ... , 100...000. Where the last number has 101 zeros.
•  » » » » » » 5 weeks ago, # ^ |   +2 Actually an even easier case is just all numbers = 1.
•  » » » » » » » 5 weeks ago, # ^ | ← Rev. 3 →   +13 No bro, if all numbers are 1 Input: 1 1 1 1 1 1 1 ......(100 1s) Output: 1 10 11 12 13 ...19 100 101 102.... 
•  » » » » » » » 5 weeks ago, # ^ |   +8 Yah you are right on your first example, sorry, thanks
•  » » » » 5 weeks ago, # ^ |   +8 codicon thanks a lot!
•  » » » » 5 weeks ago, # ^ |   +8 codicon Thanks man. Just tried using strings and it worked. Regret the fact that I knew what may have gone wrong but still didnt change it.
 » 5 weeks ago, # |   0 Alternatively, you can download test data also. They provide input and output for all test sets. And then you can compare exactly for which test case, your code is not working correctly.