Wednesday, May 16, 2018

Print binary tree extreme corner in alternate order

May 16, 2018

Introduction


It was such great experience to mock interview a USC computer master degree student, she spent less than 20 minutes to write almost perfect solution using python.

Here is python code.


Feedback


Here is the feedback I wrote for one hour 10 minutes mock interview.


Tuesday, May 15, 2018

Find the least number of perfect square numbers sum equal to given number

May 15, 2018

Introduction


It is the second algorithm in my mock interview today. I like to show my transcript here and plan to write a C# solution when I have a few minutes.

Follow up 


Here is my C# code. I made a mistake and then I fixed the bug.


Swap kth node with kth to last node in singly linked list (recursive solution)

May 15, 2018


Introduction


I had a mock interview this morning. I learned such important lesson in mock interview. Actually I tried to reconstruct a linked list involving four nodes in the linked list. Actually I can just swap values in those two nodes instead.

After the mock interview I also learned the lesson to write a recursive solution. Since I can write the algorithm in less than 10 minutes.

Mock interview


Here is the transcript at 8:00 AM mock interview.

Recursive solution


Here is my C# practice after the mock interview.

My bible for next three weeks

May 15, 2018

Introduction


It was a busy day but I did spend 10 minutes to do some research, and then I found the Leetcode solution written in C++. I choose the solutions as my bible for next three weeks.

My ambitious goal is to read as many solutions as possible, I should reduce time on wechat, instagram, I like to learn a few algorithms this time.

Here is the link.


Manhantan 2 - Booking woman in tech

May 15, 2018

Introduction


I got a coach and then I learn something by observing him how quickly he can read the problem, review my code, and discuss the solution with me on this dynamic programming algorithm.

I will write down the solution based on our discussion lasting over 15 minutes. I showed my coach the blog with C# algorithm I wrote using dynamic programming solution.




Second mock interview given by my coach

May 15, 2018

Introduction


It was early in 7:40 AM. My coach asked me if I can start early today for a session. We actually worked together from 7:40 AM to 9:30 AM. I just could not believe that.

We did review the algorithm of last mock interview, I showed the coach the algorithm Manhanttan 2, he spent around 10 minutes to think about the solution, we had great discussion. I joked that next time he and I can write some algorithm for Hackerrank contest.

Next I was asked to work on the singly linked list to swap two nodes.

The last I was asked to solve a dynamic programming solution.


Vancouver does not believe in tears

May 15, 2018

Introduction


I like to write a blog called Vancouver does not believe in tears. The story is related to implement the algorithm I was asked in mock interview called swap two nodes in singly linked list. I learned through and after the mock interview on May 15, 2018.

It is a mistake when I write down the test case. I spent time to practice the algorithm called swap kth node with the kth from the end in a singly linked list. Here is C# code.

I made a mistake in my test case, line 37 and line 38 left hand variables are exactly the same, but I tried to find the bug in the algorithm. I spent over one hour and I could explain what kind of bug it was. The behavior was so strange, I used debugger but I could not explain.

My test case is a singly linked list fro 1->2->3->4->5->6, and I like to test the swap 2nd node with 2nd to last end one node. But I made a mistake in test function, the list is created only with 5 nodes, 1->2->3->4->5.

I felt frustrated, and almost exhausted. So I relaxed myself to review one of linked list practices. I came cross one of practice using recursive function. I decided to write a solution based on the recursive function. I found the mistake in test case setup in my code.

How to work with frustration? 


I am so glad to experience the frustration again. I like to measure the level, what kind of actions I have, and later on I can come out good ideas to deal with those kind of mistake.

First let me measure the frustration level, give it rate 7 out of 10. I thought about doing really challenging practice on algorithm, but ended up working on trivial things.

I documented last time I came into tears after the mock interview. After I read the feedback from the interviewer. It is harsh and I Need to learn the lesson of learning harder.


Laundry list of excuses


I like to give possible reasons why I can not handle stress very well in my practice. I can think about several things, first not enough sleep; stress from principal applicant deadline, I need to fill the form for my nephew. And also I do not anticipate anything longer than one hour to write and debug.

In the morning mock interview, I did not simplify the task to swap two nodes's value but instead of working on node reconnects in the singly linked list. Through the mock interview, I learn that I may have done a lot of time at work, I should simplify the task first instead of messing with a complicated problem unnecessary.

I could not believe that I just did very good job for myself last week, and then next week I need to learn from the lesson again. Ask questions about the algorithm, dig deep. Define the requirement, seek the shortcut if there is one. solve the problem quickly first.

Extra 5% cholesterol

May 15, 2018

Introduction


I do not have time to practice tennis as often as I do since I start to work on mock interviews daily. But I need to handle some issue, out-of-normal-range cholesterol value. Just above upper bound not more than 5%. The doctor just told me that I should keep physical exercise and eat healthy.

In order to help myself catch up learning, I like to write my favorite topic a first blog.

Extra 5% cholesterol 


I learn to make sense the value of cholesterol. I need to spell correctly, there is e between cholest and rol. I highlighed e in the last sentence.


Principle applicant paper work ready to go?

May 15, 2018

Introduction


I have to work on a few things and help my young sister and my nephew to send out the principal applicant paper work with physical examination information. I filed all the paper work and then my nephew does not know the whole process. I have to examine all paper work, write a letter to list the documents, and fill the form again to update last 7 months status of applicant.

I even told the young man that he needs to pay land of permanent resident fee. I paid the fee and shared the receipt.

I learn to work with my sister-in-law and also my young sister. I have a nephew who chooses not to contact me directly.

Express the intent


I am open to learn from the young generation people. I like to be a coach for my nephew, but he chooses not to talk to me directly. I have to report to his mom and my young sister.

To get along with people better, I believe that I can learn from working with my relatives first.


My church revisit after 8 years

My burnaby mountain park trip

My grouse mountain hiking trip

May 16, 2018

Introduction



My friends Cai Yongmei and Dr. Huang came from Florida to visit the city of Vancouver the first time, I was so happy to hang out with the couple and experienced the beauty of Vancouver. Last Saturday we spent almost whole day on the grouse mountain.

I hiked, and then walked on the snow, and then enjoyed the company of friends. We know each other over 12 years.

I like to post some photos and videos and then we like to celebrate the good life together with friends.

Do I make things too easy?

May 15, 2018

Introduction


It is so much laughing today since I had chance to review my own code written more than 12 months ago. Is that true every 12 months you advance your programming skills? Since I learn how to come out dynamic programming solution without any headache, I found out my practice over 6 hours in the contest was so such a good thing to laugh about.

I am self-learner on algorithm problem solving. I am pushing myself to top of world level? I could not believe that I wrote so many lines of code, I documented it. The blog serves the purpose to teach me that good code is to write short, very clean code compared to the long complicated functions.

Code comparison


Here is the solution I played with stack with so many things, including extra comment up to 400 lines of code. I did it more than 13 months ago.

Laughing moment. Laughing...

I wrote simple code today. So simple and I could not laugh one more time. The code still has bugs, but I will sort out the constraints in the problem statement.

Dynamic programming solution is here written on May 15, 2018.

Keep writing some code every day and write some coding blog every day.



System design: stream service for twitter

May 15, 2018

Plan to watch some system design video 20 minutes. I like to find 10 topics about system design first, here is the article.

Good programmer starts from learning writing daily

May 14, 2018

Introduction


I had such great experience to mock interview with young master graduate student from university of Florida. He did work on the algorithm called find largest smaller key in binary search tree.

I was so surprised that he worked with me so well, every hint I gave he took action to fix the bug in the code. And so many bugs it really makes the mock interview so exciting. He fixed all of them. It is so nice to work with him. I know that he definitely can learn more and improve more.

Through the peer's mistakes, I learn the way a young graduate learns algorithm so quickly. He told me that he completed more than 240 Leetcode algorithms.


Hard working 


I gave out my encouragement comment. And the peer was so appreciated and he shared with me his experience.

I understood that as a software programmer, maybe, there are a lot of ways to improve your technical skills. But definitely good habits like learning new things, be nice, treat people nice and easy will build up more opportunity to open to the world.

Today I learned from the peer's story. Maybe I will experience his story as well. But I saw his attitude and hard working spirit. I was so proud of University of Florida. He shared his personal experience to compete for a position with number 100 each day onsite interview a global company, he helped me understand the statistics with first hand experience.

I lived in Florida state from 1996 to 2010. I am an alumni alumna of Florida Atlantic university.

Monday, May 14, 2018

Announcer badge

May 14, 2018

Introduction


It is called Announcer badge, one more badge I got on code review site, I did spend time to complete 5 minutes research. I like to document my feeling and learning here.

Announcer badge


I  like to document my badge experience, encourage more people to write and share, make learning and teaching more close to our daily life.

I was complained by my young sister who has more than 25 years teaching experience. She complained about my selfish. So I took some action to share my writing on Leetcode discussion, and I brought myself a badge called Announcer.

Let me show two images about badge information and my 22 badges first.





Here is my algorithm link on Leetcode discussion panel.

I crossed reference my two sharings, one is on code review site, one is on Leetcode discussion. I learned the announcer badge. I should give thanks to my young sister who teaches me some valuable lesson. In order to be a excellent software programmer, I should not be selfish. Writing is my favorite, sharing is also. Do not care too much your sharing. Keep writing more on other site. Give attention to open community like Leetcode discussion panel.


Behavior interview with a friend

May 14, 2018

Introduction


I was luck that my friend finally found time to train me behavior interview. We practiced together two hours, he gave me a few lessons. My biggest problem is to ramble. How to speak very clearly?

Mock interview


I will document my practice here.


Manhantan 2 - Booking woman in tech

May 14, 2018

Introduction


It is so good to review my practice on the algorithm called Manhantan 2 more than 13 months ago. Hackerrank has all my submissions of the algorithm. I was so glad to know that I can solve the algorithm quickly using dynamic programming solution.

I spent over 30 minutes to write the solution, and then debugged the code and fixed a few issues. But I still missed some constraints, I could not come out the idea to all the algorithm pass all test cases. I need to write down keywords in the problem statement.

Dynamic programming solution


Here is C# code I wrote using dynamic programming solution.

I still like to write down a few lessons I learned through the practice.

1. Line 117 the function name is not matching the work. It should be called FindMaxCandiesFromLeftTopToBottomRight.

2. base case line 129, I added the statement before debugging the code.

3. The three loops (line 132, line 134, line 140) is kind of interesting. I came out the idea when I visited the restroom.

I tried to come out the idea to prune the algorithm, minimumToDestination variable is used to help the third loop.

I made mistake on missing line 167, after the debugging, I found out that my result is always 2. So I need to add line 169, but then my result is bigger so I fixed bug to write one statement ( line 167 ). And then I fixed the issue on line 124, I added 1 to the variable timeToLive.

Funny notes but harding work spirit


I like to read my own comment written more than 13 months ago. I was very hard working, but I need to learn how to write dynamic programming solution. I like to copy the notes here.

" The idea is to start from top left node, always go right or down, and then track the  sum and max value; Because the size of matrix is 100 * 100, queue will cause out-of-memory, use stack, DFS search, try to use recursive solution if possible 200 depth at most, 100 + 100 try to get some points first, and then get the idea - 2:35pm - 7pm, now it is 7:53pm, what is the possible reason to get wrong answer? ".

I could not keep laughing, I was so glad that I moved on mock interview starting last April, 2017. At that time, I wrote broken English with a few Grammar errors here.

Because the size of matrix is 100 * 100, queue will cause out-of-memory, use stack, DFS search, try to use recursive solution if possible 200 depth at most, 





Sunday, May 13, 2018

White board practice

May 13, 2018

Introduction


I did some mock interview with my roommate Emma, she gave me a free lesson how to give a good presentation. She has full time one year experience to teach IELTS in Vancouver area.

My assignment is to write an essay about topic: handingwriting skill are declining
Q1: what reasons
Q2: Positive/ negative

What I asked her to help me is to give me an assignment she does very often as a teacher. And then I give a presentation how I will work on the assignment.

My presentation


Here is my writing:


Emma's coaching


Here is emma's notes.


Highlights of Emma coaching


You need to look at each person in the room.
You need to get every one involved. You have to ask question to see if they are following you.
Keep smiling. Hide your nervous or anxiety for presentation.
You see how many words I write, only 10 words. If you write too many words, people will focus on your writing, not what you talk.




Find minimum cost from top left corner to bottom right corner

May 13, 2018

Introduction


It is the algorithm to find the minimum cost from a matrix top left corner to bottom right corner.


Transcript


Here is my work in the mock interview. The interviewer told me that I should write the code after the mock interview, give him to review the code for next mock interview.

My next mock interview will be in Tuesday.


Mock interview 


Learning algorithm is such great experience. It is so much fun to work with a young graduate student around twenty five years old. He was very kind and also very encouraging. I spent first 5 to 10 minutes to think and communicate with the interviewer depth first search, compared to breadth first search. And then he kept asking me how you can improve the algorithm compared to depth first search. He did more than two times.

I finally came out the idea to use dynamic programming algorithm. Even though I have practice Deletion distance algorithm over 20 minutes last 12 months. But I still miss some dots to come to dynamic programming algorithm.

Arguments


I like to write down a few words about my analysis using depth first search is not optimal.

First, the algorithm is to find the minimum cost. There is no need to find actual path. Using depth first search of course takes extra effort to find path from source to destination.

The question is to ask minimum cost. I should quickly related to deletion distance.

I will do some research and figure out how I can come out dynamic programming algorithm without hints by the interviewer.

I have weakness to come out dynamic programming solution at the first place today.

Assignment


The interviewer told me to show him the code I write and he will give me some review next mock interview.

Follow up 

May 14, 2018
It is the algorithm called Leetcode 64: Minimum Path Sum.

I was asked if I worked on the problem before. I said that I did not. But actually I thought about the hackerrank contest I worked on similar algorithm. So I search all contests I played from oldest to latest one, I found the algorithm and blog called Manhantan 2.

I am so glad to learn that my last practice in the contest. I was so glad to see my hard work, and here is my C# algorithm written based on dynamic programming. The solution still has bugs with score 33.


Print binary tree extreme corner in alternate order

May 13, 2018

Introduction


It is my first algorithm to work on. I spent 28 minutes to work on the algorithm.

Transcript


Here is my transcript.


First mock interview from my coach

May 13, 2018

Introduction


I may come cross a most hard working top engineer in the world. My coach is a busy graduate student and working for top four companies in China as an intern. He has to squeeze time just before going to sleep and then giving me a mock interview for 45 minutes.

My first mock interview started from 8:00 AM PST. In less than one minute, the coach sent me a wechat message. We started our first mock interview after we first met on mock interviewing platform this January 2018.

Summary


The interview lasted 71 minutes. I finished the first algorithm in 28 minutes, and then second algorithm we discussed the solution and then I got hint to use dynamic programming instead of using depth first search, I wrote down base case and recurrence formula. And then we ended discussion of second algorithm in 55 minutes, moved on the other topics related to the future practice etc.

Feedback


I was asked to answer the question about array and list difference. And then I did not answer very well. I was told to look up Google after mock interview.

I was reminded to use negative operation to make the code more efficient. And also I was asked if I work on the algorithm recently. I told him honestly that  I worked on binary tree level order traversal and zigzag order level traversal recently.

He told me that I was nervous. He gave me the hint to use queue, since I talked about zigzag level order traversal using stack. I followed his hint to use queue instead.

I explained to him after mock interview that I have met a lot of peers through mock interview, write a complicated function in the interview and end up to get stuck. I like to write a simple function to traversal the tree by level using queue first, and then I like to piggyback the work to add the list of extreme nodes.



Saturday, May 12, 2018

Special drill for next three weeks

May 12, 2018

Introduction


It is my decision to contact my mock interview peers and then I decide to get some private lessons from those peers I like the most. Since they are working hard, best performer I have met over the practice. One of them is Tsinghua university gradudate student. I could not find time to finish over 500 Leetcode algorithms in last three years. I asked two of them to be my coach for next three weeks.

How to choose a good peer to be a coach? 


It is not easy at all to do so many things very well. It takes time to practice so many Leetcode algorithms. So it is better to have a coach and find out how to work on the practice more efficiently.

First of all, I like to figure out that what job needs a super talent software programmer.

If I have a good coach to practice at 8:00 AM to be interviewed for two algorithms 10 sessions next three weeks, then I can have Saturday and Sunday, play grouse on the top of grouse mountain this past Saturday and enjoy Sunday service with friends from Florida.

The picture and videos can be viewed from instagram here (?) very soon.

Actionable item:


Plan to study solutions as many as possible next three weeks. I need to read as many as possible solutions.

Here is my next three week's bible.




Thursday, May 10, 2018

A short email to write

May 10, 2018

Introduction


It is also best time to answer a friend's question. I met a person through the mock interview a few days ago. He asked me a few questions. How many questions have you solved in LeetCode ?  And how do you train your muscle memory?  Also, do you time yourself while working on a question? I'm trying to figure out how to improve my speed? 

My answer


I spent 10 minutes to think and write an email to answer those questions. 

Here is my answer I wrote in an email. 

I only submitted 97 out of 796 algorithms. But last 12 months, I worked on same set of algorithm around 30 of them over 11 times on one mock interview platform, work with over 300 hundred programmers together. I learn one thing a time. Some of them are hard level, and I practiced those hard level algorithm over 50 to 60 times. I really figure out how to learn one hard level algorithm very well at the end of 12 months practice. 

 The tip is once you learn one hard level algorithm very well, you will figure out how to learn other medium level or easy level algorithm quickly. 

Book reading: Microservices: from design to deployment

May 10, 2018

Introduction


I am so happy to write coding blog every day and also try to practice mock interview as well last 12 months. Now I like to start a new project, I like to learn system design. For example, how to scale a website to allow million people to watch the live matches.

I was so lucky that I had some coaching from my 22 years ago coworker today, we used to be coworkers in Shanghai from 1994 to 1996. He spent 90 minutes to coach me the basic concepts. Here is the list I should learn:

Auto scaling / Continuous integration
Big Data
Container - docker
Elastic search
Hadoop
Jason
Jekins
MapReduce
Microservice
MySQL
Redis
Rest API - state
Spark


Book to read


I was advised to read the book: Microservices: from design to deployment.

Aha, Julia is learning a a topic called 5 reasons to switch to software for load balancing. This system design project is stress free. Just be nice to your ex-coworker, and keep the friendship as long as 24 years. Just be a good student again in 20 minutes reading.

https://www.slideshare.net/Nginx/5-reasons-to-switch-to-software-for-load-balancing



Book reading: The Mythical Man-Month

May 10, 2018

Introduction


It is such a great book to help me understand two pizza team Amazon leadership principle. I plan to spend 30 minutes to read the article related to the book: The Mythical Man-Month. I like to read the wiki article about this book first, here is the link.




Tuesday, May 8, 2018

Being an interviewer: Find smallest substring containing all characters

May 8, 2018

Introduction


It is my favorite algorithm called Find smallest substring containing all characters. I worked with a peer and helped her to write a brute force solution using python language. I had chance to show how to solve the algorithm and also the peer liked me as a tutor. I enjoyed the time to work with the peer.

Mock interview 


Here is the transcript I reviewed, I gave the analysis for brute force solution, and I wrote a double for loop for brute force solution as a hint as well.


Plan to read the code camp 20 minutes. Here is hackbright academy in San Francisco. 


Being an interviewee: K messed array

May 8, 2018

Introduction


It is my favorite algorithm called K messed array. Since C# does not have class for minimum heap, I chose to write a selection sort algorithm to implement the algorithm.

Mock interview


Here is my C# code.


Leetcode practice

May 8, 2018

Introduction


It is very good practice to review last 12 month what I have practiced on Leetcode. I was surprised that I only submitted 42 algorithms.

Last 12 months


Here is the excel sheet showing my last 12 month Leetcode submission. Here is the pdf file of all algorithms submitted last 12 months.

I like to analyze my behavior to work with Leetcode and see what I should work on to make improvements.


Being an interviewer: Find largest smaller Binary search tree key


Introduction


It is my favorite thing to choose the algorithm I just learn or practice and give it to the interviewee in my mock interview as an interviewer. I did meet a programmer in Seattle with eight years experience who stays anonymous and I did mock interview him 2 hours on May 7 2018 starting from 10:00 PM. I learned through his 40 minute performance to write a recursive solution, after a few times I asked him to simplify the code. He did more than three versions of code in Java. At last moment, I showed him the recursive solution in less than 10 lines of code, I wrote in less than 2 minutes.

I like to write down a few version of code reviewed by me. I enjoy the process to be an interviewer. I know that not long ago I make the same mistake, an easy 5 minutes question I spend over 20 minutes to work on.

Through the interviewee's experience, I understand that we all need some training to solve an algorithm quickly using recursive function.

Will come back later.

Being an interviewer: Leetcode 153: Find maximum subarray product

Being interviewee: Find largest smaller binary search tree key

May 7, 2018


Introduction


It is my algorithm called largest smaller binary search tree key. I have practiced the algorithm over twenty times. What I have learned is that there are so many ideas to work on the algorithm, I should open to new ideas as long as it makes sense. What I have to do is to understand how good I can do to solve this algorithm over twenty times practice in last 12 months.

I still had some difficult time to figure out while loop, what I should loop on. I need to make sure that the search is going to left if the value is bigger than given number, and the search is going to right if the value is smaller than given number. I just quickly apply a test case using given number 17 and root node 20, I like the loop continues as long as possible.

Iteration solution


Here is my C# solution.


I was also very honestly exchanging ideas with the peer how to handle this case if I know the algorithm very well, practice over 20 times recently. He smiled and then he said that it is ok. The interviewer will try to come out the extended algorithm to find out if you are memorizing the solution or not.

I explained to the peer that I already go through the stage to try to memorize the algorithm. When I work on the algorithm, if I do not write down keywords, ask, constraints, I do not write down a list of requirements, I made a few mistakes to mix one algorithm with the other in mock interview platform. I learn from the mistake and know how to play with memorization. Follow the ritural, and then give the first 5 minutes to write down the requirement, and then write down the algorithm afterwards.

I try to work hard to avoid this kind of mistakes.

This time I did on purpose to show the peer how I work on white board testing and make sure that each line of code is correct. No spell error, no syntax error, no logic problem.

Monday, May 7, 2018

Being interviewee: Find largest smaller binary search tree key

May 7 2018

Introduction


It is my algorithm called largest smaller binary search tree key. I had a mock interview at 8:00 PM with a young graduate student in California who had ACM ICPC contest experience. We had chat first after his mock interview algorithm, I did good job to pursuade him to write down a few lines of analysis before he wrote the code for the algorithm, specially keywords, ask, constraints. It is better to gather requirement from the problem statement, instead of memorizing all requirement in the head. It was pretty relax for me to work on the algorithm after the peer worked on his algorithm called Find difference pairs.

I chose to write the iterative solution without considering the recursive solution first, and then I told the peer that I had mocked interview this algorithm over 20 times. I was told that if the interviewer can tell that I memorize the algorithm, it will be no hire by a senior engineer before. So I told the peer that I still memorized the solution, I need to go left or right and I need to get into a loop as well. Only problem I had this time is how to construct a loop, what to loop on?

The peer was very experienced and he smiled, and then he asked me the question. Can you write a recursive solution for your algorithm? I said sure, but I have never written one using recursive solution within a 5 minutes period. So I did write down the recursive solution in less than 5 minutes. And then I argued myself to run test cases using given number 17, root number 20 as a test case. And then the peer ran a few test cases using 14, 17, 27, 25, and then he said that the code should work.

Recursive solution


It is my first time to write a five minute solution using recursive solution for the algorithm called largest smaller binary search tree key. It is definitely a good algorithm for the interview as the first interview algorithm. Compared to the iterative solution, I wrote more than five minutes since I had to argue to myself a few things, while loop construction, and then started from brute force solution to traverse the whole tree.

Here is my C# code.

Sunday, May 6, 2018

Youtube CS Dojo

May 6, 2018

Introduction


I like to spend 30 minutes to go over some videos from CS Dojo. I like to get some tips quickly if I have a few hours. Here is the link.

Udemy - essential code interview questions

May 6, 2018

Introduction


It is the course costing CA $12.99, and the author is a former google engineer. I came cross his video on youtube.com and was amazed how good his teaching is. Here is the author page on udemy.com


10 minutes research


I plan to do some research on this course and also figure out if I need to purchase the course or not. I need to support him since I like his teaching.


K closest points to the original

May 6, 2018

Introduction


It is the algorithm video 10 minutes about the algorithm called K closest points to the original. I could not believe that I learn a few things from the teaching. Unbelievable good quality with 191,875 views.

Algorithm practice


There are 3 solutions which are sorting the array, selection sort, or min/ max heap.

Leetcode 140: Word break II (Add subroutine to check if breakable)

May 6, 2018

Introduction


It is the time to learn the algorithm as quick as possible. I came cross this Chinese blog and I like to generate a gist first, and then write C# code based on the blog.

Algorithm practice


Here is C# code passing online judge of Leetcode 140: word break II.

Leetcode 140: Word Break II (brute force solution)

May 6, 2018

Introduction


It is hard level algorithm called Leetcode 140: Word Break II. I like to go over some ideas through most viewed discuss first. Now it is 9:30 PM, I like to spend 30 minutes to read a few answers.

Now it is 9:39 PM. I decided to go over the blog written in Chinese first, and then make a gist based on the analysis. I like to understand the analysis from the author.

Algorithm practice


Now it is 11:03 PM.  I finally put together C# code using the idea in the above gist. Based on the original author's advice, the solution will time out for a super long string test case. I still need to work on the correct solution to pass all test cases.





Leetcode 139: Work Break (dynamic programming)

May 6, 2018

Introduction


I like the speed I can learn the algorithm using dynamic programming. I came cross this solution through Leetcode discussion, and I like to write one as well. It takes me a minute to understand the solution.




Leetcode 139: Word Break (Using BFS)

May 6, 2018

Introduction


It is my job to make the algorithm learning easy. What I like to do is to read a few ideas through Leetcode 139 Word break, and then write C# practice based on the idea.

First idea


I like to review this idea using breadth first search. The idea is easy to understand and also easy to write. The implementation is to use a queue and also a hash set. The hash set is used to keep track of the visited nodes to avoid repeating the same work.




Being an interviewer: Sentence reverse

May 6, 2018

Introduction


I just could not believe that the peer and I worked together, I tried to help the peer write a bug free code using C++. The algorithm is called sentence reverse. We spent over 55 minutes, there are still bugs in the code.

Mock interview


Here is C++ code.


Being an interviewee: Shift array search

May 6, 2018

Introduction


It is binary search algorithm I wrote for the algorithm called shift array search. I designed a binary search to apply on the array which is not sorted.

Mock interview


Here is my C# code.


Being an interviewee: Array of array products

May 6, 2018

Introduction


It is the algorithm called array of array products for my mock interview. I wrote a solution without any issue to pass all test cases.

Mock interview


Here is the C# code.


Friday, May 4, 2018

Being an interviewer: Find minimum substring containing all characters

May 4, 2018

Introduction


It is very good learning experience to be an interviewer for this hard level algorithm from Leetcode. The algorithm is hard for the first time player to come out the optimal solution using slide window, and also apply time complexity O(n) where n is the string's length.

I just learned one more time to communicate with the peer, worked on brute force solution first, and then moved on optimal solution discussion after 30 minutes.

Mock interview


Here is Java code I reviewed. I also started to ask questions about Java, and ask the peer how long they work on Java, why to choose Java for interview.

I was so glad to introduce the slide window technique to the peer, and also used the example: "AAAAABC", explained that extra four A characters can be removed for minimum substring.



Being an interviewee: Pancake sort

May 4, 2018

Introduction


It was my 8:00 PM mock interview algorithm called Pancake sort. I was very happy to work with a peer who is an engineer in Silicon Valley. The coding takes me 20 minutes to write. I enjoyed the discussion with the peer about technology he used. The company is called Hortonworks. Even though the peer stays anonymous, but I learn a few things about technologies.

Mock interview 


Here is my C# practice.


The birth of Julia's coding blog

May 4, 2018

I could not believe that I read the blog I wrote 2 years ago why I start the coding blog in 2015. I just copy and paste here from the blog written 2 years ago


Introduction


It is exciting to write the sliding window search algorithm with time complexity O(N),  N is the string's length. The similar algorithm is here on geeksongeeks.com, and also it is very close to the Leetcode 76: Minimum Window Substring.

There is a short story about the sliding window algorithm. Julia still remembered that 2 years ago in 2015 January, Julia asked to get her first onsite interview after a tech talk social event, she could not pass phone screen from top four software companies. But she likes to find out what if she has one and what she should learn.

She was asked to solve the algorithm to search a minimum substring as the second algorithm, but she failed to solve the problem on onsite interview and she could not write any code with a lot of hints. This is the first onsite coding interview she managed to get in the city of Vancouver after working full time over 5 years.

After a week analysis of the algorithm, Julia decided to start to write a coding blog, practice coding every day.

A coding blog starting January 2015


The only way Julia can think about improving the algorithm and data structure problem solving is related to learn from her tennis sports practice in the city of Vancouver. What she did is to work on tennis sport practice over one hundred hours, two hundreds hours, and then she started to play double matches and met over hundred people on the tennis court.

She understood that onsite interview is such a great help for her to understand that she needs to make life style change. She needs to find those people working hard on algorithm and data structure practice, work on something together, practice together.

She likes to give back to others, shows her generous to share, most likely she will share her failure, struggle at the beginning.

She started to write day by day, now her coding blog is like a tree planted by the water that sends out its roots by the stream (Jerimiah 17:8).

Here is the blog about the algorithm to find minimum substring using sliding window technique written 2 years ago, January 2015. This is the time Julia understood that it is important for her to start to write a coding blog to help herself. She felt so frustrated on the onsite interview but she quickly learned something related to her tennis sports practice.

This time Julia came out the idea in less than 1 minute, but she still needs to work on a few implementation details.

Follow up 


August 30, 2019

Onsite interview place - 

Time: 2015 January 
Place: Westin hotel in the city of Vancouver downtown
One hour coding interview: 

Thursday, May 3, 2018

Leetcode 269: Alien dictionary

May 3, 2018

Introduction



Plan to spend time to review the algorithm again. I like to make the algorithm my favorite graph algorithm in May, 2018.

I know that it takes a lot of sacrifice from a friend who coached me through mock interview, how to pay attention to detail. I like to write the blog to express my thankfulness to those people. Like my hitting partner on tennis court, those algorithm practice trains me to think harder, work harder.

One day I wish I can use my mathematics training over years and be able to use some of them in the work. First I have to learn how to be a good software programmer first, my crafting skills has to be improved first.


Learn how to talk in Chinese about the algorithm


It is interesting to learn how to express the algorithm in Chinese first. I did 10 minutes study and made a gist based one a blog. Here is the gist. The algorithm with some improvement is here.

Plan to write a C# solution based on the above Java code.

Past practice


Here is my past practice. I need to warm up and write a solution. It is such great warmup to review code written more than 2 years ago, here is code I reviewed and wrote this time.


Leetcode: Zigzag level traversal

May 3, 2018

Introduction

It takes me 30 minutes to rewrite the code based on my last practice more than 2 years ago. I plan to read more discussion and learn a few ideas to write the solution.

Here is my C# code written for zigzag level traversal

Leetcode 102: Binary tree level order traversal

May 3, 2018

Introduction


I like to work on three ideas to implement the algorithm called binary tree level order traversal. The peer gave me honest feedback after he mock interviewed me on May 2, 2018. It should take you less than five minutes to write, and then you have chance to move on the second question. But you actually did take 20 minutes.

To train myself to work on this algorithm, I plan to spend time to read a few hours on the discussion panel of the algorithm first.

Using extra node null to separate the level


I like to write a C# practice using extra node null to separate the level. Here is my C# practice.


Being an interviewee: find pairs with given difference

May 3, 2018

Introduction


It is a small world and the mock interview just forms a bridge for people to meet and learn from each other. I like the algorithm in mock interview, it is not too difficult but it provides us a problem to work on. Today the peer told me that he thinks that it is very important for interview to try out how two people can work together, how they communicate and work on the problem.

Mock interview


I spent first 30 minutes to work with the peer when he worked on sentence reverse. And then he helped me to work on the algorithm called Find pairs with given difference.

Here is my code with the discussion how to output the pair using original array order of small number in the pair.


Being interviewer: Sentence reverse

May 3, 2018

Introduction


I was mock interviewer and the interviewee worked on the sentence reverse. And then we moved on the discussion of remove leading, trailing middle spaces.

Here is the code I used for me to be interviewer from Leetcode 151: reverse words in a string.

Mock interview


The interviewee wrote python solution and then we had discussion, work on coding to fit into removing extra space.

Here is python code, I lost it again before I saved it gist. I should save it without any name or description first.

Mock interview


It is so interesting I met a young graduate who is preparing Google onsite in a month. I had chance to talk and learn something from the mock interview. The mock interview lasted one hour fourty minutes. I tried to figure out how good a candidate is, but somehow I understood it. The way the peer handles the problem solving, he definitely can write good code using python, also he can work on the improvement right away once I pointed out.

The peer told me that one of the important things about interview is to communicate on the algorithm, and ask questions, clarify the problem, and also talk about things.

Chit chat about my performance



He likes my way to write down analysis using keywords, ask for:, constraints. I told him that I trained myself to spend first 5 minutes to write down the analysis, like system design, talk about keywords, constraints, and what to ask for. And then I can figure out how to design the algorithm. I tried to fully use the first 5 minutes, push myself to write down things, do not memeorize algorithm, do not assume the things, write down constraints.

And also the peer likes me to talk about the algorithm, and gave out the ideas to solve the problems. I told the peer that I have worked on coding skills so many times, definitely I feel comfortable now to write most common algorithm and data structure. For me, I have to make it real, write down the analysis, and then have discussion to find the optimal solution.

The peer gave me his idea to solve the problem. It is much better than me and simple. And then we had discussion, I asked if we can do better compared to his idea. Later, I shared array quadruplet post I did on code review website with the peer.

I have worked on those interview algorithm more than ten times. I already went through the stage to memorize the algorithm, and then made mistakes to mix algorithms. I treat all the algorithms are the same. From scratch, word by word, read the problem statement first.

I got complaint about deletion distance, dynamic programming algorithm, I memorized the solution and got complaint by an Intel senior engineer, Ph.D., he told me that it is no hire if I memorize the algorithm, write something before I fully understand the problem.

Now I try to act like a teacher, a lawyer, write down the keywords, constraints. I do have lessons from hackerrank contest since I missed some important words in the paragraph. It is also good time to demo how good I can read.





Leetcode 102: Binary tree level order traversal

May 3, 2018


Introduction


It was my mock interview algorithm on May 2, 2018. I was told very honestly that I should memorize the common queue technique, using breadth first search, two loops, outer loop for each level, inner loop for each node in the level.

I decide to write a few solutions based on Leetcode 102 discussion.

Algorithm practice


Here is my C# practice to use the idea of two loops, outer loop for each level, inner loop for all elements in the level.


Wednesday, May 2, 2018

Leetcode 18: 4 sum

May 2, 2018

Introduction


My young sister always criticized how selfish I am when we have time to argue about things on wechat recently. I like to refer this personality to the algorithm I practice. I noticed that I spent time to track how many views on code review web page related to the algorithm called array quadruplet, it is waste of the time. And then I decided to move on. I need to spend attention to other people who have shared their code on Leetcode discussion on this algorithm. So I studied over 30 minutes since there are so many of them I cannot finish all, and then I wrote my first post on the algorithm Leetcode 18: 4 sum discussion panel.


My post 


Here is my sharing. I like to write down my ideas to share as all others do on leetcode discussion panel on Leetcode 18: 4 sum. I also wrote C# code to pass the online judge. Here is the C# code.

I read one post from Microsoft intern, and here is the link. What I like to say is that I learn something from the author's experience.

Being an interviewer: Leetcode 152 Maximum product subarray

May 2, 2018

Introduction


It is so interesting to work as an interviewer. I did interview a ICPC contest silver medal winner, facebook intern using the algorithm a few days ago. And today I had chance to interview a 15-years professional software engineer.

What I like to do is to tell the difference? How to approach the goal to be a super talent programmer? Experience, education, what is most important part to play the role? We can not tell, but we can do tell through problem solving on the algorithm related to dynamic programming problem.

Mock interview


Here is the transcript I reviewed.


Two stories to give out major hint of dynamic programming idea 


The subproblem is to define the subarray ending at index i, what is maximum subarray product? Why is this subproblem defined? Since it can be constructed in the series of index i, and easy to do it. Our solution is to get global maximum value for each index i.

But it is not easy for me to teach or tutor the candidate in mock interview on this idea. Basically it is not good idea to tutor peers on mock interview. But sometimes I have to learn how to give major hint, how to define the hints to make it easy for the peer to understand.

I tried on my last two mock interview but I did not do very well. Here is more detail story.

Learning to be a good interviewer is so much fun. I did talk to the peer on mock interview, while the peer worked on the test case and tried to understand my hint, I was surfing Leetcode 152 discussion, and see if there is any tip for me to share with the peer. I could not believe that the peer could not understand my hint, and let him try a few more times to get the solution by himself. Actually he could not do it.

The same thing happened a few days ago with the peer who has much strong analysis skill set. He did say that he understood my hint. But then he moved on to explain his original idea and made a few modification. I could not understand his idea fully, but he showed no interest on my hint.

Learning the algorithm together is so much fun. It is not easy, specially for people over 10 years experience but lack of constant challenge on algorithm and data structure.

I have to learn how to encourage the peer, make him less stress and get out comfortable zone to try something new.

Being interviewer: Sales path

May 2, 2018

Introduction


I am very experienced interviewer on this algorithm called Sales path. When the peer told me that he likes to write a breadth first search, and later he gave me his analysis for optimized idea, I know that he is very talent programmer. It turns out that he is currently working for Amazon two years.

Anyway, it is a good lesson for us to learn the algorithm written in Java.

Mock interview


Here is Java code I reviewed. I did not make any comments on coding style, I did ask how to remove hashmap.


Why I work on mock interview and choose to be an interviewer?

May 2, 2018

Introduction


I had a mock interview this 10:00 PM. At the end of interview, the peer asked me why I choose to be an interviewer on mock interview. So I like to write a small research on this topic.

Will continue to work on it.

Sudoku solver algorithm 


Learning one algorthm very well. It takes determination to learn one algorithm over years since I could not believe that I am too busy and I have to constantly remind me to work on the same algorithm and get better and better. This will make my life as a software programmer much easy.

It is very important for me to learn the algorithm very well in order to sustain my career as a software programmer. I like the mock interview since I love learning and teaching, and also I do see the opportunities to improve through each mock interview.

I like to write down my experience of learning Suodku solver algorithm. I started to work on the algorithm and documented my practice in a few of blogs in 2015. I thought that I did very well to master the algorithm.

I got to know the truth once I start to practice mock interviews.  To work on the sudoku solver algorithm in mock interview, one time a senior developer who works for fortune 500 gave me a rating of 1 out of 4, and later in mock interview the peer told me that I should work on the structure of depth first search algorithm. I have worked on 10 rounds of mock interview, so I have chance to work on the mock interview over 20 times. I also asked the question on code review website.

It is very important for me to learn the algorithm very well in order to sustain my career as a software programmer. I like the mock interview since I love learning and teaching, and also I do see the opportunities to improve through each mock interview.

Learning and teaching 



I remember that I used to read a post by a high school teacher in early 2006 when I worked on computer science Ph.D. in Florida, who is my second elder sister Jianhua's friend. My sister Jianhua has over 30 years teaching experience. Basically the friend wrote in her post is that learning and teaching is kind of repetition. You got so many feedbacks coming in, bad or good. You have to work on those feedback, integrate them to next teaching or learning.

Learning algorithm is kind of the same thing. You practice the algorithm through mock interview, work with different people who is also hard working. And then you will get a lot of things to work on.

Do not stop. Keep continue. Work on the same algorithm again and again. You will find things to work on besides memorizing the solution. There are a lot of challenging issues.

My mental toughness


I had a mock interview with a friend on May 2, 2018. After more than one hour mock interview, the peer gave me honest feedback. I should memorize the common solution for those algorithms. If the competitor makes it in five minutes, I take 20 minutes, I will be in trouble. I will not have chance to get the second question.

Also here is the quote:"Must do interview questions
Each topic has some building block questions which end up being used by a lot of solutions. It is important that you already know solutions to all these problems so you don't waste time thinking up the solution to these problems and focus on the question interviewer has given you because you will be judged on that. I have included some of  these questions but if you go through Interview Bit in detail you would eventually come across/cover most of these questions"


I gave my thoughts as well. Here is my argument:

I always watch those tennis professional player up and down, so that I will not get disappointed too long if I fail. I used to hit rackets to the net but opponent complained to me. I like to practice better than real interview.


I like to practice than real interview



I like to write a few sentences for this argument. I do think that the more I meet peers through mock interview, I know better to do current job. My achievement is tremendous and make me grounded. I am not trying to achieve unachieveable target, serve others if need, teach or learn.

Share the experience


I like to document my own practice. It looks like that I am the luckiest one to be able to document my algorithm practice more than a few years. I treat the code like commodity. I can produce and consume any time. I do not need to worry too much how good my code is. If it is not, I will get better next blog or next practice. If it is good, then it will be such a fascinating marketing tool for me to get connected to more people.

Love to code every day


It is like sports activity. To maintain the physical health and mental health, I always play sport and also matches to encourage myself to get in teams, and continuously learn new things.

I got feedback from binary tree level order traversal from my mock interview performance on May 2, 2018 9:40 PM. I use extra node null to mark the end of level, but there is more popular trick to use a nested loop for the current level, and leave the outside loop for the level update. I missed that part, and the peer told me the truth, honest feedback. He asked if I like honest feedback or nice sayings. I chose the honest feedback.

I practiced the algorithm over 2 years ago. I just reviewed my past practice, and also spent hours to go over Leetcode discussion first time on this algorithm called binary tree level order traversal.

Here is my C# code written for binary tree level order traversal.

Here is my C# code written for zigzag level traversal.

Being interviewee: Budget cut

May 1, 2018

Introduction


It is the algorithm I still have some confusion how to get the optimal solution. I tried to draw something and explained the algorithm starting from sorted array first element, checked if it can survive for new budget.

The peer did not ask me questions and challenge me. I like the peer to challenge me and question me if I memorize the algorithm. I like to see if I need to figure out something new to work on.

Mock interview


Here is my mock interview C# code.


Actionable Items


I need to come out some analysis about my approach. Since the requirement is to get minimum impacted recipients, the biggest number of impacted recipients is the total number of grants array. So sort the array first in ascending order, iterate the array, the first one is to consider worst case, maximum impacted recipients is 5 in the sample test case. If the budget is available then move to next iterated element.

Monday, April 30, 2018

System design: Messenger service like whatsapp or wechat - interview question

April 30, 2018

Introduction


It is so good feeling to watch a 25 minutes system design video again. The title is called Messenger service like Whatsapp or Wechat, here is the link. The author is an Amazon software engineer Ramon Lopez.


Code review: Array quadruplet

April 30, 2018

Introduction


It is so happy for me to continue to practice Array quadruplet algorithm since last March. What I have learned through over 10 rounds mock interview is that I have to continue to learn the algorithm through each practice.

It is the big surprise when I chose the algorithm to ask the peer last Saturday 10:00 PM mock interview. I tried to test a senior in the university how good he is since he told me that he had ICPC contest experience in high school.

Build a hashmap on the fly


I like to answer my own question asked five months ago on stackexchange.com. Here is the question's link. Here is my answer's link.

Leetcode 4 sum discussion panel


I have to push myself to learn from others. One drill is to read as many discussion as possible, and try to figure out new ideas, creative thinking process. I spent 30 minutes to read through the discussion, and also wrote a reply. Here is my reply link.

I noticed that I had some issues, since I keep checking code review my answer link. I know that it is waste of my time. I should spend time to read more discussion on Leetcode 4 sum.

Sometimes I notice that I have to push myself to show concern to others, people in the community, and also give out support for other people's good thoughts and work they share.

To be selfish or pessimistic, it is not working very well in this fast-paced software industry. This is the first time I make this argument.


Here is my post to show my idea and answer for Leetcode 18: 4 sum. I did spend 30 minutes to read my submission eleven months ago and then I decided to write a new solution based on my practice on array quadruplet.

One step further


Here is the reply I gave to the most view answer 6.1 K views. I shared the tip to lower down the time complexity to O(n * n).




Sunday, April 29, 2018

Being interviewer: Array quadruplet

April 29, 2018

Introduction


I had a mock interview with a young undergraduate student with ICPC contest experience. So I like to ask him to solve my favorite algorithm Array quadruplet. I think that he did one on dynamic programming, and then I tried to evaluate how good he is.

Biggest surprise was that he gave me the solution I could not understand. And then I asked him a few question, ask him to explain using example. He did perfect job to explain the algorithm.

It turned out the algorithm is optimal solution. I like to post the answer for my own question asked more than 6 months ago. Here is my question link.

Mock interview


Here is the algorithm the peer wrote. At the end of interview, I asked him to connect to linkedin, it turned out that he worked for facebook as an intern already.

I could not believe that my mock interview practice was so many surprise and I just enjoyed the talk. Somehow I complained to the peer that I do not want to study so many system design interview, I do not want to try to memorize so many things, I like to work on the algorithm with the peer on mock interview instead.

We met and talked about one hour fifty minutes until the mock interview terminated the discussion. I could not believe that I enjoyed the discussion of the algorithm so much, I never expected that I will meet a super talent later in Saturday evening.

Time complexity


The algorithm provide by the peer is better on time complexity, since the two sum preprocessing is conducted on the iterating of the array in the same time, what ever in the hashmap should be with smaller indexes. We do not need to go through the list of the items in the key value since any one of them will work. 

It is similar to all other algorithm like merging 2 packages


Feedback from the peer


You just do as you do in the mock interview practice session, you should be able to do fine in any interview. That is my advice.

Being interviewer: Leetcode 152 Maximum product subarray

April 29, 2018

Introduction


It was my 10:00 pm mock interview. We both finished our algorithms in first 30 minutes. Then we spent extra one hour 20 minutes to work on algorithms together. I asked two algorithms for the peer to solve.

Here is the first algorithm called Leetcode 152: Maximum product subarray

Mock interview


The peer worked on the solution, and then we had discussion and then our discussion lasted more than 30 minutes.

Here is the transcript.

The peer wrote a brute force solution in less than 2 minutes, code is from line 54 to line 64. Two days ago, I helped a young undergraduate student to work on the brute force solution more than 10 minutes. What is big difference. I was so amazed and could not stop expressing my biggest surprise.

And then we had discussion about optimal solution using time complexity O(n). I tried to explain to the peer that his algorithm is not so good since it could not apply to the double array. And then he said that if it is a double array then it is another problem.

One more argument we had is about the algorithm he proposed from line 88 to line 112. The problem is that I could not understand his algorithm, I was too lazy to think and I need to run a simple example first.

I decided to give out the hint, I wrote the hint from line 32 to line 45. I like to introduce the dynamic programming algorithm, and help the peer to follow the idea.

And then the peer continued to work on his idea, he wrote down the notes from line 66 to line 86. The peer is very good at writing pseudo code and explain thing.

He did told me that he worked on ICPC contest in high school, and he found out that mock interview algorithms are easy etc. We talked about codeforce contest etc.


Being interviewee: H-tree

April 29, 2018

Introduction


It was so nice to have a mock interview at 10:00 PM. I had chance to work on H-tree algorithm, and then I wrote a test case based on the advice of the peer. The peer finished his algorithm open bracket less than 7 minutes, I said so many good things about his performance; and then I told him that once I finish my algorithm, I will ask him a few algorithms and see how good he is. I finished my algorithm in less than 20 minutes.

Mock interview


Here is my C# code.


Being interviewee: Open bracket

April 29, 2018

Introduction


It is my April 28 8:00 PM mock interview, I need to write open bracket algorithm.

Mock interview


Here is my C# algorithm.


Being interviewer: Root of a number

April 29, 2018

Introduction


It is my learning experience to be a nice interviewer to work with a second year undergraduate student who studies in NIT university in India. The peer asked me the hint to solve the root of a number, so I explained to him the algorithm using line 59 to line 66. The peer was very smart and then he came out the idea to apply binary search.

Mock interview


I was not a very nice interviewer, I surfed my internet to read something about system design interview. But later on I noticed that the peer wrote a very good binary search algorithm. Better than I did when I worked on binary search algorithm first ten times last year.

Just share the fact that I have worked on binary search algorithm over 50 times last 12 months.

But this time the peer and I worked together over five minutes, we could not find the bug. It turned out that Math.pow(base, n) call is wrong, base and n two arguments are switched in the order.

I could not believe that I need to train myself hard to do trouble shooting. I need to train myself to think logically.

Here is the transcript with C++ code. I was so patient and let the peer worked on the algorithm first 40 minutes or so.





Being interviewee: Merging 2 packages

April 29, 2018

Introduction


It is my April 28, 2018 6:00 PM mock interview. I had to write the algorithm called Merging 2 packages. I also met a peer who works in Silicon Valley, and he asked me where I practice the algorithm, so I wrote down a few places I practiced.

Mock interview


Here is my C# code and also a few lines of notes to share my experience. The peer also shared system design link and he strongly recommended it to me.


Saturday, April 28, 2018

Being interviewee: Find smallest substring containing all keys

April 28, 2018

Introduction


It is my algorithm called find smallest substring containing all keys. I was so happy to write a perfect solution in 30 minutes, but I noticed that I had to slow down, work with the interviewee since he was not so strong in terms of coding. I may have to focus on the explanation of the algorithm, and also work on a small example to walk through the algorithm.

Mock interview


The peer actually asked a few questions on the test case I chose. After that, he asked me to give him some advice how to prepare algorithm and data structure interview.

I gave 5 minutes talk at least, and also wrote down some notes.

Here is the transcript.


Being interviewer: Array quadruplet

April 28, 2018

Introduction


It is my job to be friendly to the peer no matter the peer can solve the algorithm problem or not. The algorithm is called Array quadruplet. The peer was nervous since he spent time to write a test case first, and then tried to write a brute force solution after 12 minutes past. I stepped in to help and explain how to write a brute force solution.

Mock interview


I understand that the peer needs more practice on mock interview. As an experienced interviewee, I  will work on small test case, and ask for hint if I cannot solve the problem.

Here is the transcript for our discussion. The mock interview was such great experience.


System design interview questions: DESIGN A PARKING LOT

April 28, 2018

Introduction


It is time for me to watch a system design interview asked at Google, Facebook. Here is the video link. It is 29 minutes video, I finally found time to complete the video from 9:18 PM to 9:47 PM.

System Design

The lecture is very structured. Let me write down some notes.

 Abstract Vehicle
 - string licensePlate
 - enum color

Car implements vehicle, same applies to MotorCycle, Bus, Truck. The size of car is Small, Medium, Large, Extra Large.

class ParkingLot(zipCode: int)
- Spot: placeVehicle(vehicle vehicle)

class Spot(id: Long, size: enum)

4 stacks
  placeVehicle  + put in hashMap
   O(1)
  Spot: removeVehicle(vehicle:Vehicle)
     -> Lookup hashMap





System design introduction for interview

April 28, 2018

Introduction


Learning system design is kind of challenging. What I like to do is to watch a few videos on youtube.com first, and then I like to come out the idea how good those videos are.

This one I chose to watch is made by an Apple engineer. Here is the link. Let me rate this video as 10 out of 10.

I like to write down those topics I need to learn basics.

System design


Here are some notes I like to write down.

Ask good question. What features to work for, how much to implement.
Don't use buzzwords.
Clear and organized thinking
Drive discussion (80-20 rules)

- Features
- Define APIs
- Availability
- Latency performance
- Scalability
- Durability
- Class Diagram
- Security & privacy
- Cost effective

Let us move on the topics for system design:

- vertical vs horizontal scaling
- CAP theorem
- ACID vs BASE
- Partition/ Sharding Data
  - consistent hashing
- Optimistic vs pessimistic locking
- Strong vs Eventual consistency
- Relational DB vs NoSql
- Type of NoSql
   . key value
   . wide column
   . document based
   . graph based
- Caching
- Data center/ Racks/ Hosts
- CPU/ Memory/ Hard drive/ Network bandwidth
- Random vs Sequential read/write on disk
- http vs http2 vs websockets
- TCP/ IP model
- Ipv4 vs ipv6
- TCP vs UDP
- DNS lookup
- Https & TLS
- Public key infrastructure & Certificate Authority
- Symmetrix vs Asymetric key


Being an interviewer: Meeting planner

April 8, 2018

Introduction


It is the algorithm to find the overlap in two intervals. And I like to learn from the peer how he solved the problem first time with the correct algorithm, and also very good skills to write Java code.

The peer has very good working experience to work on biggest software companies in the world, China and USA. I had good understanding the programmer who worked for Tencent, Amazon and Microsoft, compared to my first practice, he is much better and also strong in the analysis of the algorithm.

The algorithm is challenging and very time consuming even for the top talent programmer in the world first time.

Mock interview


Mock interview is fun and I watched a few times through the video, how the peer got family support and work on the mock interview very hard, since his wife passed by behind in the living room. So I talked to the peer that relax, let me play with my medicine ball, take your time to come out the correct algorithm.

The peer was very busy to come out the overlap calculation, and also go through the discussion of advancing the pointer of one slots.

Here is Java code I reviewed. I also like to point out the analysis is perfect. I like to use it as my reference to come out the analysis.