NZEC exception on CLEANUP


Tried solving the problem CLEANUP.
But, got the NZEC exception for 1755709.

I tried using a bitSet instead of storing the different indices 1-N, so find it confusing where I might be going wrong.

Can anyone suggest any solution?

@mohit2088 : Hello , I just saw your code . You are reading the second line only if m!=0 . I would expect that there would be an empty line when m = 0 . I did this problem long time back and I think I did it with this assumption .
So if you have two test cases , like :
2 (number of test cases )
5 0 ( n and m for first case )
(empty line )
5 1 ( n and m for second test case )
2 ( value for second test case ).
Your code will not read the empty line since m == 0 , and then it tries to process the next case and it will try to get two int’s from an empty line which are not there , hence exception will be raised . I didn’t look into the logical correctness of your code . But I guess this is the cause of runtime error you are getting .


Thanks a lot.
Yes, my assumption that for a case with m=0, no lines would be present was flawed.

Worked flawless, with your approach. :slight_smile: