Mark As Completed Discussion

Start With Inputs and Outputs

The very next thing to do is either ask for few sample arrays, or come up with your own. Start building your test cases. It helps you start to process how to transform the inputs to get the outputs.

Try to start with a very small input, and increase its size as you do more examples. Here's what you might say:

Candidate: Very interesting problem. Alright, just to make sure I understand the transformation and result that we want, let me run through a few examples. So if I'm given [0, 1], we'd want [1, 0] back?

Interviewer: Yes, exactly. (Candidate begins to think of how to move that lone zero in the first example)

Candidate: Hm, for that one, we just needed to swap the 0 with the 1. Now, if given [1, 0, 2, 0, 4, 0], I would want [1, 2, 4, 0, 0, 0] back.

Interviewer: Correct.

Candidate: And [0, 0, 4] becomes [4, 0, 0]. Hm...