Help Me with my Solution

Why does my code fail on test case 3 ?
All elements of size[] are set to 1 initially so how can i get a sequence of zeroes ?
Here is the link to my solution-