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
Related Q & A:
- What are good ways to save up for an iPod Touch?Best solution by wikihow.com
- What are good effective ways to prepare for an exam?Best solution by Yahoo! Answers
- What are good ways to promote my website?Best solution by Yahoo! Answers
- What are good ways to get the "Last Second Bid" on eBay successfully?Best solution by ebay.com
- What are good ways for personal fund raising?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.