Introduction
I had a two hour mock interview with a friend met on interviewing.io. I like to write down some notes and help me track how many things I should work on next two weeks.
Case study
I am preparing Amazon and Facebook onsite interviews in August. He is preparing Google and Amazon onsite interviews in August.
We met on pramp.com. I gave him the algorithm to work on for warmup. The algorithm is called is graph bipartite. Here is his code with my review, I added all comments.
He told me that he always using graph algorithm pseudo code as a template.
He likes to give me an algorithm to work on after we spent 30 minutes. I chose to give him a hard level algorithm to work on since I like to learn KMP algorithm from him.
We had discussion about KMP algorithm, he showed me his code to use longest prefix suffix array to solve the problem.
Next he gave me the algorithm to work on. Find if there are increasing subsequence with length three in the array. I did not come out the correct answer, I came out partial solution to see if maximum length of any continuous increasing subarray is bigger than two.
He showed me that it is special case of longest increasing subsequence. He then showed me O(nlogn) solution using binary search.
He also showed me his solution for hard level algorithm Leetcode 214: shortest palindrome. He told me that he submitted the code while I coded my solution.
Actionable Items
The mock interview partner learns things quickly. He showed me two solutions, one is binary search to solve longest increasing subsequence, and then second one is hard level 214 shortest palindrome using same function used for KMP algorithm - longest prefix suffix array.
What I did is to show him how I can write a simple while loop algorithm and test the code using pramp.com, and then he showed me a failed test case. I explained the idea to use extra space to help and using linear time to solve the algorithm, he explained to me to work on the idea to use binary search.
No comments:
Post a Comment