Coding Style
- Leave blank space around each operations
- Give meaningful names to parameters
- Add space line between two logic blocks
For example, Implement strStr():
1 | public class Solution { |
Tips: A well-known algorithm to solve this problem is using KMP. This method can run in O(m+n) time. But usually, during a 45 minutes interview, complete this O(m*n) method is enough. So, understanding what the point the interviewer asks is very important.
Think it in this way. If I were the interview:
This guy may be my potential colleague. Is there any bug here? Because if there are many bugs, I will probably debug a lot for him when we are in a team.
Is he talktive? Well, I will give you limited conditions about the problem and I hope you can ask me for more details. Also, to every question, pay attention to the boundry condition.
When we solve a coding problem
- Pay attention to the boundry condition
- Do communication during the writing part
- When finished coding, do a test case no matter the interviewer request or not
Permutations Problems
1 | public class Solution { |
Similar Problems:
SubsetsII
Permutations
PermutationsII
CombinationSum
Letter Combination of a Phone Number
Palindrome Partitioning
Restore IP address