Different output on submission and running in Leetcode

Link to the problem

Link to my submission

It gives no ouput when submitting on 2nd sample test case whereas gives correct output when ran on Leetcode .
My idea is to make the first row and first column same as they are in chess boards , If its possible return the answer else it is Impossible
@akshitm16 @ssjgz @ssrivastava990 @cubefreak777 @tamo11 @lotthbrok :sweat_smile:

TC - [[1,1,0],[0,0,1],[0,0,1]]

Correct Output : 2
Your Output : -1

My question is not about Where my code fails :sweat_smile: , it is about why my code is failing to give any output on submission for the same test case that it is passing while I am running it on the same platform :sweat_smile:

This link may be helpful.

I donā€™t know how leetcode works under the hood, but doesnā€™t it give the input as the argument to the function that you have to fill out (e.g. movesToChessboard(vector<vector<int>>& board)) so you donā€™t have to/ mustnā€™t read from stdin?

         cin>>a[i][j];
4 Likes

Yeah, in leetcode we donā€™t have to take input, it is already available in arguments

3 Likes

Thanks :slight_smile: Making a guess as to how Leetcode works - the OP is reading in/ stealing data from cin that was intended for the Leetcode testcase reader/ checker, causing it to go haywire.

3 Likes

Ohhh Thanks , I donā€™t know how I didnā€™t noticed it , I knew that we cannot take input in Leetcode , Thanks man .

1 Like

Thanks for the help :slight_smile:

1 Like

Okkk I will see this as well , Thanks :slight_smile: