Not passing test cases on gfg

this case is not giving right output fot some cases like

1
84
1 0 1 2 1 1 0 0 1 2 1 2 1 2 1 0 0 1 1 2 2 0 0 2 2 2 1 1 1 2 0 0 0 2 0 1 1 1 1 0 0 0 2 2 1 2 2 2 0 2 1 1 2 2 0 2 2 1 1 0 0 2 0 2 2 1 0 1 2 0 0 0 0 2 0 2 2 0 2 1 0 0 2 2

hello @Gaurav_dev
image

it should be n-1.

sorry my bad…anyways thanks for the help

actually it is still not working
for test case like
1
15
2 2 0 0 2 1 0 1 1 2 2 1 2 2 0

for test case like
1
15
2 2 0 0 2 1 0 1 1 2 2 1 2 2 0

use if-elseif-else may be this resolves ur issue

it is clear now,thanks for the fast replies… :slight_smile:

:+1: . . . . . . :+1: . . . . . :+1: