Introduction
One idea
I like to promote the idea to enumerate what variables in the problem, and how many possible time complexities for the solution? Which is optimal one? How can we lower down? Do we have limitation of time and space complexity? What is upper bound?
One algorithm as an example
Stay open
It is much better to stay open when I have to write some code. Even if I do not know what I should write, I just ask one more question before I write the code. I have to give myself last chance to clarify the problem. I always forget to use data structure, extra space to exchange time for optimal time complexity. Queue, stack, heap or binary tree, what ever. It is always to scan through the list and find one to apply.
Do not write code until you have an idea how to solve the problem? I should say that please wait one more minute to let me think about the idea.
Do not be shy, and just say it. And also say that do not worry. The idea is more important compared to write the code.
Do check the time. First algorithm I should have at least twenty minutes. I will have time to write if I come out the good ideas.
Tell the interviewer I will have this structure. Go over keywords, and then write down what is asking. And then go over possible time complexity. And then brainstorm the ideas to solve the problem.
It will take a few more minutes but it is necessary in order to find the optimal solution. No rush to write the code.
No comments:
Post a Comment