For the input [0,0,0,0,0] can anyone suggest me what will be the ouput?


#1

I submitted the code and it is expected and for the input [0,0,0,0,0] it shows me the ouput is 1 which is wrong.


#2

The actual output is 6.
You can always check the output by yourself, just click on the “See expected output” button, which is below the explanation of the test cases and then you just need to follow the instruction.
For this question the input format is
line 1- Size of array.
line 2- Size of array “empty space” input element separated by empty space


#3

When the input is 5 0 0 0 0 0
the expected output is 0


#4

Your input should be
5
5 0 0 0 0 0


#5

I think for input [0,0,0,0,0] with A = 5, output = (A -2)(A -1)/ 2 = 3 * 4 / 2 = 6

I will explain the logic below.
For 3 zeroes 0 0 0, you can split them in only 1 way : 1 + 1 + 1
For 4 zeroes 0 0 0 0, you can split in 3 ways(1 + 2) ways : 2 + 1 + 1, 1 + 2 + 1, 1 + 1 + 2
For 5 zeroes 0 0 0 0 0, you can split in 6 ways(1 + 2 + 3) :
3 + 1 + 1, 2 + 1 + 2, 2 + 1 + 2, 1 + 1 + 3, 1 + 2 + 2, 1 + 3 + 1.
So for (n + 2) zeroes, you can split them in 1 + 2 + 3 + … + n ways = n(n + 1)/ 2 ways
or you can split n zeroes in (n -2)(n -1)/2 ways