Tuesday, March 13, 2018

Leetcode 333: Largest BST subtree

March 13, 2018


Introduction


I just came cross the algorithm called Leetcode 333: Find largest binary search tree, and then I had chance to interview the peer in mock interview. He did very good job to explain the algorithm, write pseudo code, and also explain the algorithm using the test case to me.


Code review


I will review the algorithm and mock interview transcript later on. Here is the link.

Here is my C# practice based on the coding blog using optimal time complexity O(N).

Leetcode 10: regular expression matching

March 13, 2018

Introduction


It is my most favorite algorithm in 2018. I was told to write the algorithm using recursive function in mock interview, and I did spend more than 30 minutes to write, I should analyze the algorithm and write it in less than 25 minutes.

Code review


Here is the code I wrote in mock interview today 7:15 PM today. I need to work on the improvement of speed, I took almost 40 minutes to write the algorithm.

One idea I have is to go over Leetcode 10 discussion, and study some discussion using recursive solution. I will plan to study a few hours and get some good ideas and code to work on.


Leetcode 319: Bulb Switcher

March 13, 2018

Plan to work on the algorithm Leetcode 318: Bulb Switcher.

Leetcode 318: Maximum product of word lengths

March 13, 2018

Introduction

I like to work on a few algorithms a day. Here is the one.

Leetcode 333: Largest BST subtree

March 13, 2018

Plan to study the algorithm based on the coding blog here.

Monday, March 12, 2018

How to predict the candidate the possibilities of success?

March 12, 2018

Introduction


It is 20 minutes talk by Gayle Laakmann McDowell on hackerrank, called "Deconstructs the engineering interview process". Here is the link.

Interesting talk


I like to write down a few arguments and then think about them more carefully.

Ensure that the person is smart. The person can learn the technology and also ... 15:00/ 26:20
The algorithm is challenging, multiple hurdles, ..., no cool math,  ... 16:05/ 26:20
Talk about boot camp, transition to IT career, ... 18:00/ 26:20
He is very smart person, ..., 19:30/ 26:20
Bias, try hard? do it best? ..., 20:00/ 26:20
Bar raiser? ..., 23:00/ 26:20
Consensus? ..., 24:00/ 26:20
Are the person smart? attribute? 24:30/ 26:20


Julia's notes



I like to put down some notes here first, and then decide to highlight something interest.



Interview purpose?
to predict who you want to hire, who will make a good employee.


Argument: why the interview is not realistic?

interviews should be realistic

Argument 1:

a good interview is one that is predictive and good candidate experience too


Argument 2:

it’s also not predictive because all you’re really testing is someone’s knowledge


What is to simplify their intelligence? How to assess the candidate's problem-solving skills?

When you stick to basic computer science, when you stick to basic design and algorithm, they should be there if the interviewer is doing the right thing, to essentially assess the candidate’s problem-solving skills, to simplify their intelligence.

And problem-solving skills and intelligence that is actually a very, very important thing for a developer.

Challenging, hard problem, not see the problem before, to prepare a check list:

they need to ask questions that candidates haven’t solved before that are challenging, that are challenging because it’s actually a hard problem and not because it tests obscured knowledge and see how the candidate solves a hard problem.

How to move through the problem? can you make progress on it?

What is qualitative analysis? 

Dynamic programming algorithm?

Weak problem solving skills, never do well in those questions.

candidates who are just ok, given them 10 of questions, and then he/ she will do very good since dynamic programming is incredibly formulaic. So ok candidate looks like a great candidate. So dynamic programming is not a very good interview question.

There are so many other problems out there that are going to not be as biased.

How to tell that the person is code money, not done anything challenge?

You want to find people who will be good, who will be able to do cool things, not actually people who have.

What kind of people do you need to be careful in the interview?

People who do a really good job of making what they say sound more complex than it really is.

What to focus on?

You should really focus on figuring out how this person deconstructs the problem and it’s okay to give hints and it’s okay if the person actually solves a problem with a hint. Don’t ding him or her for that.

What to avoid?

based on a trick or which is based on a math formula

How to define hard question? How to separate hard question because of obscure knowledge?

No tricks, not cool math, things whatever -> good hard question

Having questions that have multiple like hurdles, that can be multiple parts to the problem, so it can be a bunch of fault questions. It can also be just a problem that has multiple optimizations to get the most...

A good rule of thumb there is, you’re kind of struggling and you’re trying to give them a hint and you have a part-time figure out how to give them a hint without giving everything away, that’s probably not a good question.


Insecurity, how to deal with it? 

given an example using binary search tree,

Please google into a self-fulfilling prophecy?

Sunday, March 11, 2018

Asynchronous Programming in JavaScript (with Rx.js Observables)

March 11, 2018

Introduction


It is 9 hours 33 minutes course. I was told to learn asynchronous programming in JavaScript by a peer met on mock interview platform, a frontend web developer in Silicon Valley. What I like to do is to go over a few hours courses first and see if I can learn something new.


30 minutes research using Google



Bitmask dynamic programming

March 11, 2018

Introduction


I chose to go to Willingdom church and then shopping this Sunday. Afternoon I spent a few hours to work on quora.com to answer questions related to dynamic programming. Now it is 9:34 PM, I am watching the video called: Episode 20 - Bitmask Dynamic Programming.

FloorBoards problem


Where is the algorithm problem statement?

Leetcode 269: Alien Dictionary

March 11, 2018

Introduction


It is time for me to review graph algorithm called topological sort. Here are a few blogs I documented my practice more than 2 years ago, in 2016.

Course schedule, here is the blog.
Alien dictionary, here is the blog one; here is the second blog.


Algorithm practice


It is so interesting to read the blog I wrote more than 2 years ago. I like to laugh about it, the writing style is kind of different, but I am so glad to know that I can trace what my thought process and learning process after 2 years. It is so sweet to read what I did write and draw. I felt so good to enjoy my own work, review the learning process again.

What I like to do is to write a C# version, and also find 3 ideas in discussion panel and write a C# version for each idea.

Also I like to post a question on code review website. I need to learn better this time.

Actionable Item


Plan to review the old algorithm related in Leetcode. Leetcode 133: clone graph, Course Schedule and course schedule II.


May 3, 2018

I had a mock interview with the friend. And he told me to work on the alien dictionary algorithm. I do not need to write the code, but please tell him how to work on the solution.

I remembered that I worked on the algorithm before, a few years ago. And then he asked me what kind of graph algorithm I can apply. I said that it may be topological sorting. It is a graph algorithm. But I do not remember too much detail any more.

Saturday, March 10, 2018

Find smallest substring containing all unique keys

March 10, 2018

Introduction


It is my most favorite algorithm called "Find smallest substring containing all unique keys". I had a 10:00 PM mock interview, and then the peer solved the problem using less than 20 minutes. I could not believe that he wrote such great solution.

After mock interview, we discussed a few algorithm. He advised me to work on the algorithm called Leetcode 688: Knight probability in chessboard. I had a short discussion about the random process, and he quickly told me to study the algorithm.

I am so glad to share my favorite Leetcode blog, former ICPC coach's link to the peer. The peer already solve over 500 algorithm on Leetcode. We had discussion over 80 minutes, I learned a few things about the problem solving.


Code review


I did review Java code, here is the link. Later I like to write a C# version of the algorithm.


688. Knight Probability in Chessboard

March 10, 2018

Introduction


Dynamic programming algorithm is more advanced compared to recursive function, depth first search algorithm. I like to write down some note to document my practice, time spent is longer than three hours.


Algorithm practice


I did read one blog to document the analysis of the algorithm with the code, so I went over analysis word by word, and organized the idea first and put into the gist. But I could not understand the algorithm.

So I continued to search more blogs to read, and then I found one with the graph to explain three dimension dynamic programming. I understood the idea to apply dynamic programming algorithm.

Next I worked on code from discussion panel and then converted to the C# code. But it still took me more than one hour, I had to debug the code and pass the failed test case.

It is so interesting to learn the algorithm by going over the steps. It is not difficult but it took me a few hours. I think that it should take less than one hour in total.

Here is the gist I created for understanding the dynamic programming algorithm after I read a few coding blog and one discussion on Leetcode.com.

Here is the code to implement in two dimension array instead of 3 dimension, since we do not need to save all intermediate steps.

Here is the C# code to pass all test cases on Leetcode online judge 688.



Advanced Asynchronous JavaScript

March 10, 2018

Introduction


It is such a great adventure to take the three hours course called Advanced Asynchronous JavaScript. I will spend next 30 minutes to watch the course.


Course study notes




Decrypt the message

March 10, 2018

Introduction


It is the good practice for me to be an interviewer. I learn from every practice.


Interviewer practice


Today I had chance to give hint, and then I explained the algorithm asked by the peer. I made a mistake to try to help coding, I added the prefix sum sentence before source[i] is calculated.

Here is C++ code I reviewed. The whole interview only took 38 minutes for both of us.

Linear scan algorithm

March 10, 2018

Introduction


It is good practice on mock interview again on linear scan algorithm. The time I spent is 8 minutes. I will examine a few things, analysis is clear or not; the coding style can be improved or not.

Code practice


It is such a great activity and this is my first mock interview this Saturday. I like to work on the algorithm and try to find something to work on as a programmer.

Here is my C# code with analysis.

JavaScript: the hard parts

March 10, 2018

Introduction


Once a while, I like to do a short research to entertain myself. I was thinking about the advice from a peer working in Silicon Valley area startup, you should take some JavaScript courses on frontendmasters.com.

I am still working on the organization skills. I need to get my clothing packed nicely and give more space for myself in my home today. It takes time to get organized those clothing I own, I like to get those clothing stuff next two weeks as packed as possible. It is also the good time for me to take a course on frontendmasters.com JavaScript course in the same time.

I know how to take my JavaScript to next level, I have to spend time to work on some great course today. 45 minutes a time. Maybe I can spend more than one hour today.

What is most exciting part of JavaScript? It is so hard to read some of JavaScript code. What kind of engineering mindset behind those feature. I will find out more.


JavaScript: the hard parts


The JavaScript course is called JavaScript: the hard parts given by Will Sentance. I like to spend a few hours on the course today.

Time spent on the course is from 3:00 PM to 7:50 PM.



How to read the algorithm?

March 10, 2018

Introduction


I reviewed the mock interview this January 25, 2018 as an interviewee, I was asked to solve the algorithm to find shortest continuous subarray that contains all of the values from the set. After a few minutes to go over keywords, I told the interviewer that the algorithm is exactly the same one I practiced over 20 times last few months called "Find minimum substring containing all unique keys".

How to read the algorithm?


Here is what I did, I wrote down keywords:

Keywords:
 given a set with integer -> >0, distinct
 given an random integers
Ask for: 
Shortest -> greedy
continuous -> stop -> 
subarray -> 
return subarray itself ->
minLength =


Algorithm review


I just copied my analysis with pseudo code from the mock interview. The interviewer told me to go over the algorithm with him using pseudo code, so I did explain the algorithm in detail.

Here is the mock interview practice.

Leetcode 611: Valid Triangle Number

March 9, 2018

Introduction


It is the first time I chose the algorithm in my mock interview as an interviewer. The peer worked on the algorithm in March 9, 2010 10:00 PM. I think that it is the good start for me to master a medium level algorithm called Valid Triangle Number on Leetcode.com. Usually it takes 10 practices to master one hard level algorithm on Leetcode.com. For the medium level, I also like to practice over 6 times. 

This is the third time I worked on the algorithm last 6 months. I did have one mock interview discussion back in Oct. 2017, and then one mock interview in February 2018. 


Code review


The time complexity analysis is so critical in algorithm problem solving. This algorithm can be solved using two pointer techniques and the time complexity can be lowered from brute force solution O(n3) to O(n2). 

Also as an interviewer, I also learn quickly to identify the solution written actually ending using time complexity O(2n). 

I like to encourage myself and also the interviewee try the best, and heed the lesson of failures in the mock interviews. 

Here is the code I reviewed. The code works, but the time complexity is worse than brute force solution with O(2n).


Friday, March 9, 2018

CAP theorem

March 9, 2018

Introduction


It is so exciting to replay my two mock interview of January 2018, and then it is time for me to take the advice from the interviewer in the mock interview. One of interviewers told me to work on system design as well.

In one of my mock interviews this January 2018, the interviewer evaluated me after I worked on two algorithms in 50 minutes, and he told me that I should start to work on the system design. And he gave me some advice, CAP theorem is the first one.

I have to start to practice on system design, since at work I have to make choice for new website, what technology I should choose, how many things I should plan to learn, react/ web pack, and then I also have to learn how to design the system.

I am always too busy. But I find out that no matter how busy I am, I still waste a lot of time on wechat social apps. It is so hard to make real connections to people, face to face, and work on something together and make things happen.


Wechat communication pitfalls


There are so many pitfalls in wechat communication. I have done some research and also shared one of tips to my younger sister.

I constantly check wechat and read other people's post; I also constantly write too much on wechat, chat with my family.

Why I cannot make my system design like wechat app, I constantly look up and think about the design?

Make system design like wechat app


I like to study system topic 5 minutes a time. I like to work on system design at least 10 times a week.




Learn how to speak assertively

March 9, 2018

Introduction


It takes time to replay my two mock interview today. Now it is 12:20 AM, and I have 20 minutes to go to finish my second mock interview replay. I have to go to work tomorrow. I need to stop any time.

Things to work on


I like to work on my speaking like what I do in terms of coding. I ask questions on code review of stackexchange, and quickly I got improved on code readability and other benefits. I like to find wasy to work on my speaking as well.


Thursday, March 8, 2018

Flatten dictionary - recursive function

March 8, 2018

Introduction


It is my favorite recursive algorithm to write today 8:00 PM mock interview. I met the peer second time, and I laughed about it and chatted a few minutes and then moved on the problem solving. I could not believe that this mock interview is so smart and also helpful for me to build so many good friendship with peers. The statistics of meeting same peer last 12 months is so exciting, I learn to work with the same peer 1 x 5 times, 5 x 3 times, 5 x 2 times.

Flatten dictionary


I like to look into C# typeof, why it is not typeOf I thought. Please google it and find out the reason behind the naming convention.

Here is my C# practice code with the analysis.

Actionable Items


Julia, you have to spend time everyday to get better on C#. Please start from GetType(), read my C# book for a few pages.


Prepare to be a good cheerleader

March 8, 2018

Introduction


It is hard topic to write but I like to write one for myself and also my friends. It is the fact that the interview is number game. You have to compete with others, no matter how good you are, there are only 30% will pass the phone screen. I have to learn how to be a cheerleader to support the friend with some facts and also valuable advice.

Research and hard work


I started to work with a few peers and helped each other to practice mock interview. It is hard for every one of the peers. They all target for top 10 software companies. Based on the fact that only 30% will pass the phone screen and only 20% will get offer from onsite interview,  two steps the failure rate will go high as 94%, only 6% of my friends can make it.

I have to learn how to be a good cheerleader when the peer comes to me and practice with me in a few hours practice. And also I like to learn how to learn from them, and encourage them if I have chance.


Spiral matrix print algorithm

March 8, 2018

Introduction


It is my most favorite algorithm in 2018. I learn so many lessons from the algorithm, and I can count so many hours I have spent on the algorithm. My most favorite experience is documented here, one thing I did not tell that the first mock interviewer on anonymous platform in 2018 failed me on this algorithm and marked me as poor as the technical skills. I did not write fully functioning code following the idea using direction array and automate the direction change.

One more interview


I chose the algorithm to interview the peer on March 7, 2018 10:00 PM. The peer spent near 45 minutes to complete the algorithm.

Here is C# code I reviewed.

Even though I have worked on the algorithm so many hours, I did not perform very well as an interviewer yesterday. I preferred one while loop instead of three loops with while/for/while, I confused and made wrong judgement to say that for loop will have dead loop, actually the for loop direction array only has size of 4.

Actionable Items


I like to replay the mock interview I did on January 23, 2018 to work on spiral matrix print algorithm. After 30 days of mock interview, I like to compare myself with all my 13 interviewee to work on the same algorithm.

What should I work on to perform better through mock interview?



Wednesday, March 7, 2018

363. Max Sum of Rectangle No Larger Than K

March 7, 2018


Introduction


It is my plan to do lunch and learn. I need to start to work on the hard level algorithm daily. Best time to think about the algorithm is lunch time.


Pluralsight.com course study

March 7, 2018

Introduction


It is hard for me to read how many hours I spent on pluralsight.com courses. I did subscribe the pluralsight.com last 12 months, but I did not spend time to work on courses as I should.

How to fix the issue? 


I need to spend more time on the pluralsight.com courses.




Hitting partner on tennis court

March 7, 2018


Introduction


I had such great time on tennis court today. I had a sick day for my tooth pain, and then I went to see dentist and get referral to see periodontics.

I went to the central park tennis court around 4:00 pm. I worked on the warm up activity to play against the wall around 20 minutes, and then a young person invited me to play on the tennis court with him, he likes to short distance rally. It is still chilling out there in the city of Vancouver, 5 of 8 tennis courts are empty. I could not believe that the hitting partner has such great control of tennis ball, I said to him that we two can hit each other nonstop over 20 minutes. This is the first time I felt that I sweated and that feeling was so good. We played rally around 30 minutes.

Great hitting partner


Most of young people I know are working on double tennis game, but in terms of working on foundation skills, they are not so good to rally and get good control of the tennis ball.

When summer is here in the city of Vancouver, we have a lot of people playing tennis; but what happens is that those people with top talent will only play with the same in the elite group.

Today it is the exception. I was invited by a player who is one of those elite players, even though he plays same courts over years, I never has chance to play with him; since we never talk and hit tennis ball to each other on the court, I was so surprised that he hits so powerful shot when we play double games and he was my partner.


Leetcode 233: Number of Digit One

March 7, 2018


Introduction


It is part of lunch and learn. I like to work on this algorithm for Wednesday March 7 lunch time. I read through the blog about the solution, and it helped me understand the algorithm.


Lunch and learn


Usually it takes me 20 minutes to finish a lunch. I like to get it done by going over the blog, and write down my notes. I may only focus on the thinking process.




Binary search tree inorder successor

March 7, 2018

Introduction


It is my time to work on the binary search tree inorder successor. This time I had a better presentation.

My analysis and code


Here is the gist I created for my mock interview.

Analysis of the algorithm


After I have practiced the algorithm over 10 times, I start to come out new script for my analysis. I talked in the following this time and it was very welcomed by the peer with over 10 years experience in top 10 software companies.

I like to traversal the tree and then it is very easy to find the successor through the array. The access of the array takes O(1), but the traversal takes O(N) time since it is inorder traversal.

One way to beat the time complexity is to look up from the given node, either going down to the leaf node or going up to the root node. The maximum height of tree is the time complexity which is O(logn) in average.


Canada retirement research

March 7, 2018

Introduction


Canada is my country last few years. I am a Canadian citizen. I have to work on the research and then find out what I should prepare for my retirement in the future.


An article to read


I put together the article and reorganize them to fit into my reading style.

Here is the gist written in Chinese.

Search auto complete system design

March 7, 2018

Introduction


Sometimes you only have 30 minutes but you want to practice system design. That is what I did, I found the blog, and then read word by word, put them into a gist, and also most of important, tried to read the C++ code and see if the code matches the idea in the design.

One thing I also did is to reorganize the analysis and fit into my reading style. I add small headers to make the paragraph more readable.

System design practice



Here is the gist I created for my 30 minutes study. I will write C# code based on C++ code, it should be easy task.



Tuesday, March 6, 2018

Interval algorithm

March 6, 2018

Introduction



I enjoyed to be an interviewer and also learned how to develop the solution from the peer's approach.

Here is the transcript with the code I reviewed. I also like to learn from Java programmer.

Minor hint


It is the interviewer's job to give out the hint. What I did is to draw two intervals and then let the interviewee figured out how to advance the interval.

Here is one of cases:

slotsA       ________________
slotsB  ______     ______________

Another case:
_________________
  ____    __________

In less than five minutes, the interviewee made choice from start time early one to end time early one. In other words, the early of end time of interval will no longer need. It is so excited to see that the peer came out the solution in such quick time.



Find smallest substring containing all keys

March 6, 2018

Introduction


It was so exciting to know that the peer got the algorithm when I booked the interview early this afternoon. I know that the algorithm is hard level, and definitely it is very interesting to learn how the peer will solve the algorithm, specially if the peer does not work on the algorithm before.


Code practice


I know that the hard level algorithm is biased for the people never working on before. So it turned out that the peer came out the linear time solution with optimal time complexity, but the design has flaw which could not find smallest substring.

This is the first time I evaluated the idea as the interviewer, and then I came out the counter example to explain the defect in the design on line 35.

What I saw is that the peer was very calm and approached the problem, and then wrote code ready to run the test cases.

Here is the code I reviewed. I also learn some technology and know more about react framework. I did spend 30 minutes on react course before the mock interview today.


Monday, March 5, 2018

Lunch and learn

March 5, 2018

Introduction


I like to work on 20 hard level algorithms based on the blog in a week. The idea is to get to know more hard level algorithm, so I can get very busy thinking about the algorithm, read various ideas to solve the problem.

I can use the lunch break of each weekday, and then give the hard level algorithm a nickname to help me explore new algorithm.

Do not go to lunch break until I have a hard level algorithm.

Here are the hard level algorithm:

Leetcode 233, 239, 265, 269, 273, 282, 281, 291, 302, 308, 312, 317, 329, 330, 336, 340, 352, 354, 363.




Four sum algorithm

March 5, 2018

Introduction


It is the classical algorithm n-sum algorithm, n is four. I met a peer the second time, and he advised me that I should work on a small test case when I work on the algorithm. So it is much easy for the peer to understand me and my idea to solve the algorithm.

Algorithm practice


Here is my C# practice.

The peer asked me the question on the code of line 30, what if item[0] < second? that is a very good questions. I gave some explanation, but after the mock interview, I thought about carefully.

False argument:

Since first two numbers are selected in brute force ways, so it is impossible. Otherwise the numbers are already found and return statement will terminate the double for loops already.

It is not true. Here is the counter example I ran through the platform:

[1, 2, 3, 4, 5, 9, 19, 12, 12, 19], sum is 40

The program will find [3, 9, 9, 19], but it should be [4, 5, 12, 19].

Actionable Items



It is the second time I met the peer. Originally we plan to have a meetup this coming Wednesday as well. I prepared a meetup plan, here it is.

I also learn how to catch up everything I need to work with different talent. Every time I work with different talent, I understand that it is most important to focus on foundation of computer science and algorithm.

Leetcode 11: Container with most water

March 5, 2018

Introduction

Plan to work on the algorithm called container with most water.




Sunday, March 4, 2018

Work on cipher and decipher

March 4, 2018

Introduction


It has so many benefits to practice same algorithm again and again. I just realize that I can solve dynamic programming algorithm like Leetcode 91: decode ways this weekend using dynamic programming techniques.

Algorithm practice


I had one more practice on the algorithm to decipher the message. I wrote the code in less than 20 minutes. Here is C# code.


Complete Intro to React, v3 (feat, Router & Flow)

March 4, 2018


Introduction


It is the time to watch courses on frontendmasters.com. I chose to watch the course called "Complete Intro to React". Now it is 5:53 PM, I already spent near 49 minutes to finish the first lesson called "Factories & Props".


Leetcode 424: Longest repeating character replacement

March 4, 2018


Introduction


It is the first time I practiced mock interview with a peer and the mock interview lasted more than 2 hours. One of algorithms we discussed is Leetcode 424: Longest repeating character replacement.


Algorithm analysis


I have practiced the algorithm find smallest substring containing all unique characters on mock interview so many times. So I just apply sliding window technique to the algorithm as well.





Leetcode 91: Decode ways

March 4, 2018


Introduction


It is so surprising that I can solve the decode ways to apply dynamic programming techniques. The conversation is like this. The peer asked me if I can solve the problem since he was asked in one of mock interview and then he failed to solve the problem since the idea of two pointer technique is not working. He was told to solve it using dynamic programming.

Dynamic programming is so much fun and I can quickly solve the algorithm after 12 months continuous practice on the same algorithm over and over again, and also learn from each peer when they work on those algorithms. After I failed several times on constructing the dynamic programming lookup table in two dimension, I finally build a template for myself to follow.

Two most favorite dynamic programming algorithms are deletion distance and regular expression matching. Usually what I like to do is to construct a look up table, work on base case first, and then figure out recursive formula. Detail can also look up here.


Algorithm practice


Here is the transcript I worked on in mock interview with a peer together. It is such great experience to share with the peer. I believe that once I have practiced dynamic programming algorithm on mock interview platform last 12 months so many times, I just apply the technique and find that it is not hard to figure out anymore. Here is the link to look up my practice on Leetcode 10: regular expression match hard level algorithm, including the blogs I worked as an interviewer as well.

What I did is to work on test case 1238712, build up a dynamic programming lookup table. And then go through from the left to right and find the answer 6 for the test case 1238712.

We had discussion together over 20 minutes on this dynamic programming lookup table, after we carefully went over the detail, I was told that the result is correct. The peer also went over to build the table by himself after I demoed how to construct it step by step.

One fact is that the peer shared with me the solution first, but I did not have to read the code the peer shared with me at all.  I just told him to build a lookup table, work on a simple test case first.

Teaching and learning is so much fun since the peer is very busy and short of time. He has to prepare two interviews for top 10 software companies in less than one month. I am glad to learn from his experience as well.

One algorithm a time.

My personal advice


The peer told me that he only did one round of mock interview, after he finished all 30 question he stopped. He does not build strength if he keeps working on new algorithm.

Compared to the peer one round mock interview experience, I have more than 6 rounds. But what I found out is that I work on the same 30 algorithm over and over again. Even though I have to work on those dynamic programming algorithms over and over again, I worked on Leetcode 10: regular expression matching more than 30 times with various peers, I also kind of picking up a lot of things through those practice, from recursive function to dynamic programming, various languages from ruby programming to C++, Java and C#.


Clone a binary tree with a random pointer

March 4, 2018

Introduction


It is such a big surprise that I had a mock interview this Saturday 8 PM. The peer gave me the algorithm to work on, clone a binary tree with a random pointer.


Code practice


Here is the transcript for my mock interview. I did make mistake and did not handle the random pointer properly.

I should not apply recursive function on random pointer since it will end up a dead loop.





Hackerrank university codesprint

March 4, 2018

Introduction


I still like to learn something from university codesprint 2018. I played university codesprint in 2016 and 2017, but in 2018 I did not have chance to play the contest.

I spent one hour this Saturday to go over the codesprint leader board and then study those top ranking players by country.

Study report


Here is the blog I received from the email about the contest.


Actionable Items


I like to keep the good habit to play Hackerrank contest in 2018. I am planning to play some contest in short future. I like to push myself and challenge myself in the contest, work hard to get some medals.

I have two hobbies, one is to play tennis sports, another one is to play Hackerrank contest.





Saturday, March 3, 2018

Leetcode 56: Group anagrams

March 3, 2018

Introduction


I had a mock interview March 1 8:00 PM, the peer asked me to solve the group of anagrams. I remembered the conversation I had with an engineer in mock interview before, he told me that he got full score of 4 on anonymous interview platform, and then I told him that I solved the algorithm correctly over 25 minutes, but I only got 2 out of 4.

The correct solution should discuss different cases. If words are short, then it is ok to sort the words, and use sorted words as keys of anagrams. Otherwise, we can define the anagrams keys using self-defined keys.

Mock interview practice


Here is my analysis in the mock interview. 10 minutes, no coding.


Set up a goal

March 3, 2018


Introduction


One of my goal in 2018 is to review first 500 Leetcode algorithms. I know that so many of young graduate students have completed over 500 Leetcode algorithms. If I like to be a serious programmer, I am better to understand the data structure and algorithm very well before I move on to work on some web technologies.






Leetcode 416: Partition equal subset sum

March 3, 2018

Introduction


It is the medium level algorithm in the Leetcode algorithm. I spent 30 minutes to go over the discussion first and then prepared my study notes. What I did is to go over one of Leetcode blog with over 350 algorithm, and then I came cross the algorithm. I could not understand the solution on the blog, so I looked up the discussion panel instead.


Algorithm practice


Here is my practice study notes. Here is C# code.



Leetcode 494: Target Sum

March 3, 2018


Introduction


It is so hard to find time to practice new algorithm. Even I work on the algorithm, I also like to try to figure out the algorithm by myself instead of looking up the discussion.

Algorithm practice

First I spent over 30 minutes to go over the discussion, and understood the algorithm with the analysis first. In order to practice better, I also created my own gist, so I can go over word by word, and then read the code line by line. Here is my gist to take notes for the discussion.

Here is the C# practice based on one of discussions.


Leetcode algorithms training

March 3, 2018

Introduction


It is good idea to separate coding training from the analysis of the algorithm. I plan to work on Leetcode algorithm blog and try to go over medium and hard level algorithm daily, push myself to learn some new algorithm daily, at least three hard level algorithms.

Here is Leetcode blog. I also like to choose the medium and hard level algorithm as the interview algorithm for mock interview practice.


Thursday, March 1, 2018

Leetcode 336: Palindrome Pairs

March 1, 2018

Introduction


It is 8:00 PM mock interview. I asked the peer to give me a Leetcode algorithm to work on. He chose Leetcode 336: Palindrome Pairs.

Here is the analysis I did around 10 minutes.

Algorithm practice


Plan to practice algorithm multiple times.

I like to study this solution.

Recursive function question

March 1, 2018

Introduction


I like to find some algorithm easy to solve and use it as the first mock interview algorithm. 

The link is here

Problem statement:

f(n) = 3n + 1 if n is odd or n/2 if n is even. Collapse sequence refers to each number according to this formula until the sequence becomes equal to 1. Find the number ( which is not greater than 10000), which will have the longest Collapse sequence. 
      
For example:

3 > 10 > 5 > 16 > 8 > 4 > 2 > 1 = run length = 8


Problem solving



The ideal case is to go over the example n = 3, and then follow the definition of the function, find out that each intermediate steps like the following: 3 > 10 > 5 > 16 > 8 > 4 > 2 > 1, run length = 8.

The next step is to write the calculation using recursive function. The first step to go over n = 3 takes 5 minutes, writing the recursive function takes another 5 minutes.

Wednesday, February 28, 2018

JavaScript: From Fundamentals to Functional JS, v2

Feb. 28, 2018

Introduction


It is the second month I subscribed the frontendmasters.com. The first month I spent less than 5 hours on the website. I have to discipline myself and work on some courses.

JavaScript course


I plan to spend two hours on this course first in short future.

Leetcode 289: Game of life

Feb. 28, 2018

Plan to write C# code to practice the algorithm called Leetcode 289: Game of life.

Deletion distance

Feb. 28, 2018

Introduction


I had a mock interview on Feb. 27, 2018 10:00 PM. I wrote deletion distance algorithm again.


Code review


Here is the C# code.


Computer maintenance

Feb. 28, 2018

Plan to work on the algorithm called Computer maintenance.

Bus station

Feb. 28, 2018

Plan to work on the algorithm called Bus station.

Single number IV

Feb. 28, 2018

Plan to work on the algorithm called Single number IV.

Tuesday, February 27, 2018

Find smallest substring containing unique keys


Feb. 27, 2018


Introduction


I had two mock interviews as an interviewer and the algorithm is find smallest substring containing all keys. I had chance to observe how top university graduate learned the algorithm from the scratch. I know that it is hard level algorithm, even though one of peers is top graduate and very well educated, but understanding the idea and putting them into the code are two different talent. I just learned that the peer wrote a portion of the algorithm to use a hashset to check sliding window containing all keys or not.

The code was so buggy and even I could not handle the code very well. I missed the bug even after I reviewed the code. It took us more than 10 minutes to work on the code together.

Through the process, I definitely could tell that the peer was working very hard. The peer communicated very well.But coding takes some practice. It cannot be shortened without failure, mistakes, and all kinds of issues in-between.


Code review


Since I reviewed the code, I should claim part of the ownership of the code. I should copy the code and remind myself later on, be more careful when I review the code.

The mistake is
unorder_set<char> map
...
map.insert(arr[left])
map.insert(arr[right])

The char should be str[left], str[right] instead. I made the same mistake before to mix two variable names, from that on, I always go ahead in the beginning to change the variable names in the meaningful way.

Exponential algorithm research

Feb. 27, 2018


Introduction


Float number and operator algorithm is not too difficult but most of interviewees including myself cannot reduce the exponential algorithm to linear algorithm the first time. I spent 30 minutes to be an interviewer on Feb. 27, 2018 10:00 PM and then also had chance to review the algorithm again.

I like to do a small research how to reduce exponential algorithm to linear algorithm.


An algorithm book


I found a book to read and actually I spent over 30 minutes to read the book. It is called Exact Exponential Algorithms

What to learn from a data scientist?

Feb. 27, 2018

Introduction


I had chance to work with a peer two days ago who is a data scientist working for a biggest bank. I like to do a small research, what to learn from a data scientist quickly in 30 minutes to help him solve Spiral Matrix algorithm?


Monday, February 26, 2018

Lintcode 818: Subset with target

Feb. 26, 2018

Introduction


I like to try various ideas and one of ideas is to read the analysis on jiuzhang.com, and see if the analysis in Chinese can help me understand better on the algorithm.


Analysis in Chinese


One thing I like to do is to write down the Chinese analysis first, and then translate them into English.


Lintcode 819: Word Sorting

Feb. 26, 2018

Plan to study the algorithm called Word sorting.

Here is the solution blog.

Lintcode 820: Rectangle

Feb. 26, 2018

Introduction


I plan to study the algorithm called Lintcode 820: Rectangle.

I read the analysis based on Jiuzhang.com. It is so interesting.

Hint given by Jiuzhang.com

Enumerate two points crossed in rectangle, and use hash to judge if the left two points are existing.



Lintcode 821: Time intersection

Feb. 26, 2018


Introduction


It is very good habit to write a blog for each algorithm. I like to learn some new algorithms and this algorithm is called Time intersection. Here is the link.

Algorithm


One of solutions is here. I like to study the algorithm based on the gist I created for the algorithm.


Sunday, February 25, 2018

Find minimum substring containing all unique keys

Feb. 25, 2018

Introduction


It took me 25 minutes to analyze the algorithm and also write C# code. I used exactly 30 minutes to complete the task.

Code review


Here is the C# code passing all test cases.



Comparison to the practice 5 month ago


The code I wrote is much more simple compared to the one I wrote more than 5 month ago, I can look up the code through the question I asked on stackexchange.com.

The while loop to handle left pointer is much simple using one variable to count unique keys in sliding window. The loop invariant is clear and short compared to the one asked in the code review. The loop invariant in the while loop in the code review is giant expression and should be shortened.

Spiral matrix algorithm

Feb. 25, 2018

Introduction


It is so exciting to learn some ruby and also learn how the peer wrote the algorithm quickly with only two edge cases mistakes, one is one row and another one is one column case.

Code review


Here is the ruby code I code reviewed.

Most important is to observe how top programmer can find out where the code will fail in less than one or two minutes, and then start to think about the fix. In less than five minutes, we worked together and put the fix together. Amazing speed to fix everything. Only thing I did is to ask the peer to think about one row and one column edge case before he likes to run the web compiler.

Line 26 and Line 32, Line 26 one more checking is added "x_min < x_max"; line 32 "y_min < y_max" is added.


Learning time Sunday day night



The Sunday 8:00 PM mock interview is such a great surprise, I had chance to learn how a top programmer and lead in the medium size team performs so well and work with the interviewer so efficiently on my favorite algorithm Spiral matrix.

Becuase of my super performance as a mock interviewer, I had chance to get to know the peer and then I could undertand how a person works very well in mock interview, he did very well in industry as well.

Array of array products

Feb. 25, 2018

Introduction


It is 4:00 PM mock interview. I had to work on the dynamic programming algorithm. In the analysis, I analyze the right to left dynamic programming method, and I need to work on two multiplications each iteration. But I wrote down a line on line 58 which is wrong:

product[i] = product[i] * arr[i + 1] 


Code practice


The peer gave me the hint, and then I wrote down line 63 and line 64:
line 63:  rightProduct   = 1,
line 64:  rightProduct *= arr[i + 1]

I like to figure out what I should do to come out the correct analysis in the first time. If I am a teacher and I teach algorithm every day, I may come out a few ideas to help myself to follow certain steps to write correctly on whiteboard. 

Right now I only emphasis two multiplications in right to left iteration using dynamic programming methods. But I still could not connect dots in between. Do not worry, next time I will make it perfect. 

Here is my code practice in C#.

Find first missing number

Feb. 25, 2018

Introduction


It is part of my training idea, practice until you cannot get it wrong. I had a mock interview this morning at 10:00 AM. I did write down the idea to do in place swap to find the first missing number. And then I wrote code with a few bugs, I failed a few test cases, and then I fixed the bugs on line 15 and also line 16.

Practice until you cannot get it wrong


One thing I like to train myself through mock interview is to pay attention to small detail. The peer asked me to work on the optimal solution using in place, and then I came out the idea but I did say something to change the value to negative one if the value is bigger than the array size. And the code I wrote was not correct, I ran into index-out-of-range error and failed a few test cases. I fixed the bugs of course very quickly.

Line 18 swap function should be called only after the index is in the array's range.

Here is C# code.

The mistakes I made in my first writing just reminds me that I have to train myself hard than before.

JavaScript and bootcamp

Feb. 25, 2108

Introduction


It is the best thing to do in the Saturday morning. I had a mock interview at 10:00 AM. I had chance to meet one  young programmer, and also know the boot camp of hack reactor, and also learn some JavaScript and have chance to practice binary search algorithm with the peer.


Code review


The peer shared me with advice to take a look a JavaScript book: Eloquent JavaScript. I reviewed the JavaScript code, here is the link.

One thing I did is to share the tip how to round up the value in JavaScript by yourself, line 17: parseInt(candidate * 1000 + 0.5) / 1000.0. The JavaScript type conversion can be completed using parseInt function.




Friday, February 23, 2018

Neurodiversity hackathon

Feb. 23, 2018

Introduction


I like to write something for my favorite Microsoft hackathon called Neurodiversity Hackathon.

It is the learning experience, I did not know how good people are to work on hackathon. It is like China open in Beijing, I had chance to watch the top professional players how to train themselves in practice court in 2017. In practice court, I saw players practice together and how they cheer each other, and I was so close to players, sometimes only a few meters away.

I had the opportunities to learn from two team members how they wrote code using Microsoft emotional API and then successfully did the work.

What is autism?

What is Microsoft emotional API?


Here is our code ! Get excited!


Here is the link of code.

Here is the place for the project on linkedIn.com.

What is my plan after the hackerthon?



Longest arithmetic progression algorithm

Feb. 23, 2018

Introduction


It is my ideal learning to share my practice on code review website,  I know that it takes a lot of practice for me to master a dynamic programming algorithm.

I spent hours to study and write C# code, and when I like to share my practice with other people on code review website, I have to go over the reading material again and also think over again carefully. I find that it is very good experience. It is good to help others later on if I choose the algorithm as a mock interviewer, and also it is very helpful for me to examine my past week's hard work, what I should improve as a competitive programmer.

Are you currently working?


Two days ago I attended HackerX event in the downtown office Visier. I met two employers and both of them asked me the same question. Are you currently working? I know that it is very interesting question.

I am working full time.

I also try to improve myself by practicing a lot of mock interviews. I also like to invest some time to help others, learn to be a coach to help others to achieve their goals.

I start to practice with some peer met on mock interview platform, so I had chance to practice some algorithm together with the peer. I enjoy learning and find myself pick up more soft skills. Being a software programmer can be so much fun.


Algorithm practice


I spent one hour to review the algorithm and managed to post the question on the stackexchange.com website. Here is the link.

Wednesday, February 21, 2018

Leetcode 140: Word break II (VI)

Feb. 21, 2018

Introduction


I like to practice the idea shared by the students with a coding blog and also with a record solving more than 500 Leetcode algorithm. I like to learn from the player. Here is the link.

Here is the idea I learned from hard level algorithm regular expression matching on mock interview. After I practice over 10 times with high ranking peers, I quickly learned so many things and am confortable to write a dynamic programming solution.

I like to choose 10 people to learn from and then write code based on their sharing.


Leetcode 140: Word break II (VI)

Feb. 21, 2018

Introduction

One idea to learn a hard level algorithm is to give some support for the other people. I found the post with sharing tips how to avoid TLE error, so it is good to try the idea as well. Here is the link. I voted before I try the idea.


Leetcode 140: Word break II (V)

Feb. 21, 2018

Introduction


Plan to write my fifth practice based on the idea using DFS + DP + Trie. Here is the discussion link. The student completed more than 444/761 questions. I like to learn from the player.


Algorithm practice

Feb. 26, 2018 8:45 PM
Here is my C# code. The class TrieNode's design is interesting. It took me sometime to figure out and know that it will work.



Leetcode 140: Word break II (IV)

Feb. 21, 2018

Plan to write C# code based on this Java code DFS with pruning idea. Here is the link.

Leetcode 140: Word break II (III)

Feb. 21, 2018

Introduction


It is a good idea to study some code and then write the idea using C# programming language. I do know that one thing I can improve to learn a hard level algorithm is to read as many as possible ideas with solutions. And then I should practice some coding.

Specially the first hour of the day is best time for me to train myself to write good code.

Here is Java code using DP and Trie. I like to write one using C#.

Leetcode 140: Word break (II)

Feb. 21, 2018


Introduction


It is my idea to learn the hard level algorithm. Write at least 10 implementation and write as many ideas as possible.

Here is the idea for my second practice.



Tuesday, February 20, 2018

Hackerank: Road in hacker land

Feb. 20, 2018

Introduction

It is my favorite algorithm called union find algorithm. It can be Kruskal algorithm. I did have a lot of practice recently. It is so good to come back to work on the algorithm again.

Algorithm study 

Plan to review the algorithm by studying the blog.

题意
给一个联通的无向图,求所有点对之间的距离和。其中每条边的距离都是 2 的幂且互不相同。
题解

  • 每条边距离为 2 的幂且不相同,意味着选择长的边很可能是不好的。
  • 这道题跑最短路显然不大可能,因为需要求所有点对的距离和。最优解是最小生成树,接下来来证明。
  • 假设最优解不是最小生成树,那么去掉其中长度最长的边(长度为 k)后再增加若干条长度小于 k 的边仍能使其联通。先去掉最长的边,那么有一些点对会无法联通,这些点对的距离至少为 2^k,现在增加一些边使其联通,那么这些点对的距离至多是 2^0+2^1+2^2++2^k−1<2^k,从而得到一个更优解,所以假设不成立。
  • 既然是最小生成树,那么需要求一下这棵树上每条边的贡献,这个问题就比较简单了,跑一边 dfs 即可。

Coding


Please use the code for Union find algorithm Island count II for the template, and apply the same technique on this algorithm. Here is the link. 

Quick union algorithm

I like to review the practice on quick union algorithm. Here is the link: 

Quick find algorithm

I reviewed the quick find algorithm more than one month ago. Here is the link: 


A mock interview discussion

I remembered that the peer gave me the question and test my disjoint set data structure. I chose to use depth first search and then had some idea to use hashset only data structure. Here is the discussion.


Algorithm blog beyond my level

Feb. 20, 2018


Introduction


I chose to stop playing Hackerrank week of code 36 since I know that I have to work on more on mock interviews instead. But I did catch up things on week of code 36, I spent around two hours in the contest to try to solve the hard level algorithm. One thing I followed up after the contest is to look up submission of the hard algorithm, I went over all submission with full score on the hard level algorithm, checked profiles one by one. A few of them are working for Google, and a lot of them are players I know before, but this time I did find a nice player with great sharing his coding blog.

It is kind of different feeling. I do not want to stop on Leetcode algorithm only. I know that those algorithms are serving best for the interest of interviews, but I like those algorithm hard and make me excited and could not stop thinking about all the time.

In other hand, I do know that my learning of algorithm should also focus on the foundations.

Algorithm blog


It is hard level algorithm blog. All those algorithms are beyond the normal interview of Google/ Facebook questions. But it is good for me to train myself once a while.

Here is the list of algorithms on the blog.

My Tennis life: Lucie Safarova Episode 1 "Don't Let Coach Rob Do The Dishes"

Feb. 20, 2018

Introduction

I used to take videos for my tennis training. And then I like to do something these days for my training of mock interview.

Here is my favorite videos and I like to learn from those professional tennis players. Top 10 ranking players really give the fan good insights how to work with coaches.


Surviving the WTA tour ... after 30

Feb. 20, 2018

Introduction


I like the creative ideas from the great coach. I was not a great coach and then my nephew did not like to take my advice last few months. I wrote a blog to document my frustration.

It is time for me to learn from my favorite tennis player and coach, here is the video called surviving the WTA tour... after 30.


I want to be a good coach

Feb. 20, 2018

Introduction


Life is so tough and then I learn the hard lesson. I have so many friends who works as a computer professor in university of China, I spent over four hours to do research and got some advice from them last November, but I could not help my relative, because he refused to take my calls and answer my wechat, I talked to my brother over and over again. This February he did not pass the minimum required score, the graduate admission test was in this January, 2018.

I like to do some research and work on a few things. Why I can tell that he will fail from his behavior? Does good student have a good pattern of learning? Showing curiosity or having a good attitude?

Why the math is tough subject for my relative?

How to guide him to prepare for an graduate study in Canada in short future?




Train insane or remain the same

Feb. 20, 2018

Introduction


I always like to answer people why I continuously practice mock interview. I believe that I treat it like a research project. I like to find out what I can learn quickly through those practice.

I love to meet people and then have discussion related to the algorithm and data structure. I just treat the mock interview as one of my research projects, things I can work hard and then see if I can make a difference on myself or the peer. Learning and teaching are most interesting things I like to do.

I love to teach algorithm and data structure, I go through those long hours to work with peers on algorithm problem solving. From those experience, I educate myself to be super patient when I meet an algorithm and I need to break through in less than 20 minutes.


My two mock interviews


One thing I did last weekend is to go through the mock interviews from a startup company, and so surprisingly I passed two round of mock interviews, first one is average 2.7, second one is average 2.5.

Life is such a great teacher. One of my friends told me that he did first one 3.2 but second one did not pass passing bar 2.5, which is below 2.0.

So I suddenly find out that I should think about it. Do not take it for granted. At least I should write down and then later on I can tell something from this experience.


Leetcode 301 Algorithm practice


I like to figure out how to improve my practice. Just before the mock interview to work on remove invalid parentheses, I worked on leetcode 301 hard level algorithm continuously from February 3 to February 7 2018, and my goal was to practice over 10 times and also tried various ideas. Here is the list of practice by searching the blog using Leetcode 301.

One thing I like to look into is that I could not recall the tip to remove invalid parentheses. The most simple way to remove invalid parentheses is to remove unmatched close bracket first, and then reverse the string, and then handle the same subproblem.

What I can tell is that the practice does not help right away for the mock interview. I got the average score 2.5, but score of coding is 2.3. I did know that I just practiced the algorithm and got my hands on those ideas one by one, but I could not quickly enough to apply related work to the problem solving right away. The interviewer gave me 5 minutes talk after mock interview, he told me that the first algorithm took me around 30 minutes which should less than 20 - 25 minutes.

What if I did not review the algorithm, and went over all the practices I did over 6 hours.


Sunday, February 18, 2018

Find if there is a rectangle in binary matrix with corners as 1

Feb. 18, 2018

Plan to work on the algorithm. Here is the link.


Leetcode 140: Word break II (I)

Feb. 18, 2018

Plan to work on the algorithm called Leetcode: word break II. Here is the link.

I like to start to practice over ten times, using various idea.

The first practice is based on the discussion link here.

Count the number of the ways an integer can be represented as a sum of consecutive positive integers

Feb. 18, 2018

Plan to work on the algorithm, the link is here.

Longest arithmetic progression

Feb. 18, 2018


Introduction


It is the most difficult dynamic programming algorithm I have worked on before. I just could not believe that we do not have a lot of blogs and articles to talk about it. I was thinking about posting one on stackexchange.com in short future.

One thing I like to look into is how the startup company in Sillicon Valley chooses algorithm for the phone screen, what kind of talent is at the top of the free market now these days?

I do know how tough it is to survive a 20 minutes mock interview using this algorithm.

Plan to work on the solution. Here is the link.

Algorithm practice


Here is the C# code practice I had recently. I did find a blog with test cases. After I went through the test case, I understood the algorithm and how it works.


Actionable Items


I like to read the papers related to the algorithm, and see if I can understand the paper one day. Here is the link.

Here is the post on stackoverflow. And the answer I voted is here.



Leetcode 109: Convert sorted list to binary search tree

Feb. 18, 2018

Introduction


It is so excited to share my practice experience today. I had discussion with the peer on the algorithm Leetcode 109. The peer asked me to give him a tree problem, recursive solution problem. His request is based on the fact that recursive function is hard to figure out but it is easy to write in a few minutes.


Mock interview discussion


The peer wrote his analysis and spent around 10 minutes. I asked what is time complexity for his algorithm. He told me that it will be O(N2). So I chose one of leetcode discussion and then asked him having a discussion based on the solution provided over there.

Here is the discussion we had on the post on the leetcode discussion. O(n) time solution with O(1) space.

I will write down 5 minutes talk I gave to the peer. I just could not believe that I did make some comment and also the peer seems to like my comment.


There are two things to talk about related to the algorithm:

1. First the binary search tree inorder traversal will output the tree nodes in the ascending order;
2. If there is only one node in the sorted list, how to convert the list the binary search tree? What is the time complexity?

Definitely the node will be the root of the tree, and then left substree is empty and right subtree is empty.  Assume that the hint is given to traversal the tree once from the list.

The recursive function is designed this way that it is against the intuitive. The tip is that do not overthink, be a lazy and relaxed programmer. Work on the minimum coding and thinking. The linked list will travel once to next in the recursive function. If the linked list is one node, the travel will go to null from the start node.

The reason I made this talk is to remind myself that next time I come cross the problem, I will not be nervous, and I can figure out in less than five minutes.

Hashset and trie data structure design

Feb. 28, 2018

Introduction


It is such a great blessing to have a peer to share his experience. I learn one more algorithm from the peer today. The peer told me that I should not choose Trie data structure right away, I have to ask questions to collect use cases, and then define the data structure for each case.

20 minutes discussion 


Here is the algorithm we discussed in 20 minutes. I tried to give out a solution using Trie, and then I define Trie class using recursive tree.

It is most important to write a basic solution using recursive function first. Here is C++ code I like to review later.


Research about algorithm practice

Feb. 28, 2018

Introduction


It is the good idea to choose one research topic in the Sunday and then I like to find some good arguments to think about in short future.


Short research


Here is the article I read. I like to go over word by word, and organize them in the best format.



准确来说,刷题风是2013年之后开始普及,那么为什么呢?2013年后和之前的硅谷相比发生了几件事情:

Please understand a few concept first:

30W package
flg - Facebook, Linkedin, Google
ios/android bootcamp
rsu
startup
刷题最高
洗脑活动

Facts:

1. Facebook上市并开始盈利,形成了以前硅谷Google一家高薪和后来两家互抢的情况(当时还有Linkedin)。注意到 2012 之前其实 Google 的薪资只是略高于一般公司,没有达到某种量级的不同,后来就成了 30w 包裹成标配的感觉.

2. 股票价格上升. 美国互联网经济进入黄金时代,这带来的就是创业潮(泡沫),各种 startup 为了抢人,反正 paper money 不是钱,各种以 rsu 形式发送的“大”包裹开始出现,flg的 30w 算啥,“价值百万”的 rsu 要不要?上市后还很可能 double!马上财务自由!

生活在硅谷是一种什么体验?

就是刷题的体验!

国内的以为硅谷是什么创新,是什么灵感,是什么天才。硅谷的中国人就是继续发挥着国人考试的天赋,把工作面试硬是做成了高考准备一样的刷题模式。

你以为到了硅谷就是发挥你的聪明才智像国内鸡汤文写的什么“工匠精神”一样认真潜心做一个东西N年?你当码工是傻逼么?

哪里钱多就往哪里走,或者哪里可能钱更多就往哪里走. 这才是硅谷精神!

当你年收入少的时候,别人当你是笑话;

中国的高考是寒门子弟翻身唯一机会,而在硅谷,刷题则是在校留学生、小公司不得意者、创业失败者翻身的唯一机会!因此在硅谷形成了一个在全世界都看不到的现象:刷题成风,世人皆刷题。

硅谷的所有公司,就是用着这些题目对面试者进行最基本的筛选。

你是大学教授?哦,来做个题看看先,请实现上面某个问题的算法并用java或c++或python来实现. 嗯?你不会写代码?we decided not moving forward.

你是某公司 CTO 或技术总监?来,我们来做个 bfs 的题目。讲讲思路行不行?讲思路啊,讲完请在面前的白板上把你的思路写成可以运行的程序代码。15分钟过去了,还没写出来?we decided not moving forward.

你发表了研究论文无数?真牛逼,来,我们来做个题目比如在一个数组中找出4个数的和等于某个给定数字的所有组合,要快哦!。20分钟过去了,怎么,你居然没写test case?sorry, we decided not moving forward.

悲伤和喜悦的故事每天都在硅谷发生。和中国的高考一样平等,所有人,无论你是教授、公司老板、技术大拿、经验丰富的工程师、名校学生、烂校差生、学文科转行的,也不管你面试的职位是初级工程师、高级工程师、技术带头人。在这里都面临着同样的门槛:白板做题实现算法


Catalan number

Feb. 18, 2018

Introduction


It is my favorite quote saying that practice until you cannot get it wrong. On Feb. 17, 2018 I practiced the algorithm Catalan number but I got it wrong.

I had some issue with understanding n-grid.

Code review


I will look into the issue later. Here is the C# code.

Word count practice

Feb. 18, 2018


Introduction


It is hard for me to master the algorithm called word count practice.  I have to work on the string manipulations, such as lower case, remove extra chars, and split string using regular expression, and then group by the value and sort by input string order.


One more practice


Here is one more practice I did on Feb. 17, 2018 10:00 PM mock interview, I wrote 20 minutes.

Is the smartest one anonymous?

Feb. 18, 2018

Introduction


One a while I will choose a topic to do research, today I have a mock interview and then I learn something from the peer. Since the peer is working on important phone interview in next week, he chooses to stay anonymous. I think that it may be a good sign that he is super talent and will be next great top programmer.

Anonymous is good choice


Let me do some research on this topic. 10 - 15 minutes and see if I can make some progress on this research.


Feedback 


Let me share the feedback I got. So I know that the most important lesson for me to learn is to stay humble, and also work hard.


Remove invalid parentheses

Feb. 18, 2018


Introduction


It is best opportunity for me to work with another peer on the same algorithm. I write the algorithm through mock interview last Saturday and then continued to practice a few hours using C#. I also have chance to review C++ code from the peer. Learning algorithm is such a small group activity, I have to learn from others and start to get to know more about C++ through code review.

Today I got some C++ code to review on the algorithm called remove invalid parentheses.

Code review


Here is the C++ code.


Find smallest substring containing unique keys

Feb. 18, 2018

Introduction


It is my most favorite algorithm in 2018 called find smallest substring containing unique keys. That is the algorithm I have practice over 10 times from March 2017 to February 2018. And also it is the most popular interview question and I had one in 2015 January. I had a very good experience 45 minutes since I could not pass the phone screen, but I learned to be open and welcome the challenges as a programmer, show the world that I do care about learning the algorithm, and keep working hard as a software programmer.

This algorithm is the reason I start to write a coding blog starting from May 2015. I knew that I was not so good at learning, but I just started to document my learning and my emotions like feeling of struggling and then enjoy the journey to be a good thinker in algorithm and data structure.


My experience of interviewing


It is the Sunday morning 10:00 am mock interview. The peer had to work on the algorithm, and I worked with the peer 70 minutes until she finished the code, and also passed all test cases.

The first 30 minutes I went over my own blog to review the past practice, and once a while I stopped and gave some advice to the peer.

I do enjoy the interview. I do not have coworker as a programmer in my work place, I am a solo programmer. I really know that it is my own task to find the chance to work with people.

I learn from my experience on this algorithm, so I also like to share the tips to the peer through the mock interview.

Here is the C++ code I reviewed, and the code passes all test cases.

Here is the comment I wrote to share the advice after the mock interview.

My feedback after the mock interview


The peer worked very hard and also very open to advice, took the hint. The peer wrote the algorithm around 70 minutes including discussion, fixing all the bugs etc. 

I like to share that I could not finish the smallest substring algorithm in my first five practice on the mock interview platform, in 30 minutes. I had different issues, but last 3 or 4 times I kept got very good peer to help me, one is really good. Please take a look here, the peer helped me.  And the other one is also good, the peer helped me to pass all test cases in 30 minutes, here is my practice blog. 

Just practice the same algorithm again and again, work on one thing a time.