How to prepare a good interview?

What are good ways to prepare these questions in programming interview?

  • For example: print tree by level can you do it without storing an extra int per node? can you do it without two queues? The last two questions is hard to prepare during interview because you don't have the standard to evaluate this. During the programming contest like ACM/ICPC and Topcoder, we only care the complexity and correctness of a program. But when you practice interview program on leetcode, you finished a problem, and passed all tests, you don't know whether the 2 questions above will happen in other words, the code satisfied the interviewer , so how to prepare it? The only way I can think is to read other's code to broaden your horizon when you practice interview problems.But it's still not a good idea because you don't know the standard.

  • Answer:

    1) You can perform a BFS to print tree by level. 2) Yes. a) You can push the level of a node along with it in the queue. b) You may now print a node with a space when popping it from the queue. c) Before printing it, check what is the level of the node. If it is greater that current level, print a newline character and change current level to this level. 3 ) The above is done using just one queue. You can prepare for such questions on http://carrercup.com

Anonymous at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.