Facebook interview question?


  • 0
    S

    I was asked below question in an interview test?

    0_1516190158527_Screen Shot 2018-01-17 at 10.55.16 PM.png

    And these were the questions?

    0_1516190793567_Screen Shot 2018-01-17 at 11.06.07 PM.png

    • **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?


  • 0
    B

    1,
    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)

    3,
    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.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.