I was asked below question in an interview test?
And these were the questions?
**For 1: Issue must array index out of bound and hence change the loop variable upto 2.
For 2:** I don't know what it is doing? Its just matching 2 consecutive element of a column of an array and if equal then multiplying first one by two and then it checks out of these consecutive element if first one is null, then copy next column element and put value of that element to null.
For 3: I have no idea?
Could Someone explain me about this question and there answers?
1, array index out of boundry;
2, for i, it should go from bottom to top, because i+1 changes during iteration and it's value is checked again.
2, tis function looks like the game 1024, same blocks are combined and one block is released(set to null)
1, don't use fixed size, use list of dynamic size;
2, this code only can do bottom to top, add support to do from left to right, right to left, top to bottom, like the game 1024
3, use generic element type, not only int.