Saturday, March 24, 2018

Being interviewer: Find minimum path sum from root node to leaf node in tree

March 24, 2018

Introduction


It is such great learning experience to be an interviewer. I had chance to learn from the peer to solve the algorithm called Find minimum path sum from root node to leaf node in tree. I just could not believe that he wrote so clear in the analysis based on breadth first search using a queue. I also like to learn Python from 30 minutes interview, I just copied what he wrote on the paper, and then asked a few questions later on.

Code review


The peer came out the idea to prune the algorithm, if there is a minimum path sum, then it can be used to prune the path by checking current path's sum value.

It is long time for me to think breadth first search using Python, I had chance to learn how to write Python queue. Basically in Python there is no queue class, we have to specify to insert in the front using insert function, and then pop function from the end.

Here is the python code.


Largest smaller value in binary search tree

March 24, 2018

Introduction


It is still very challenging problem after I work on the algorithm more than 5 times. I enjoy the talk about the algorithm. Actually I have more understanding about O(n) time in order traversal after I work on this algorithm called Largest smaller value in binary search tree.


Mock interview practice


Here is my C# practice.



Sorting algorithm

March 24, 2018

Introduction


I had two days vacation and also had a friend visiting from Shanghai. I just came back to work on mock interview, I had some difficulty time to run whiteboard testing, and then need some time to fix the bug.

Code review


Here is my C# code to pass all test cases. I made two mistakes in my first writing, and then I had issues to pass all test cases. I found the problem on line 15 and add line 20.


Being an interviewer: Leetcode 54: Spiral matrix

March 24, 2018

Introduction


I spent time to work with the peer on the algorithm called Leetcode 54: Spiral matrix on Feb. 5, 2018. It is time for me to review the Java code and figure out what to learn from the peer.

Code review


One thing is sure that the peer has much more competitive status compared to me in terms of career. I like to review the Java code and later on I will find something to work on.

Here is Java code. What I have to do is to replay the audio and get context of the interview. The presentation of code looks like missing something.






Being interviewer: Leetcode 54: Spiral matrix

March 24, 2018

Introduction


One thing I do very good is to treat myself very well. Specially on learning an algorithm. I am like a super talent algorithm teacher, I teach myself first. What I do is to reach out top-talent people in Sillicon valley and also pacific area, and then figure out how they learn the algorithm in 30 minutes mock interview.

One algorithm I ask over 14 time is called Leetcode 54: Spiral matrix.

Code review


Here is the Java code I reviewed on February 1, 2018 mock interview. It is such a beautiful solution, using direction array and also use extra space to mark visited.


AngelList - Where the world meets startups

March 24, 2018

Introduction


It is my favorite thing to do this Saturday morning. I had a mock interview, I spent less than 10 minutes to finish my algorithm, and the peer also finished his algorithm in less than 25 minutes. So we had over 20 minutes to chat about the jobs, careers, and things interesting to look into.

One thing the peer shared with me is to look up the website called AngelList where the world meets startups.


Startup 


I like to learn how technology advances, but most of time those startup companies help our society move forward with technology and good service to enrich our life. 

I used to work on a startup company back from 2000 to 2001. Some of my Chinese coworkers really grew from the startup company Trendium and later built up strong career after three to five years working for the company. 

Startup is exciting and also very challenging. 



Being interviewer: Leetcode 54: Spiral matrix

March 24, 2018

Introduction


I had over 14 interview experience to ask interviewee to work on Leetcode 54: Spiral matrix. I like to go over each practice and then review the code. I am too busy to try new algorithms, it is still very good to review my past experience and figure out something to learn.

Code review


Here is my Feb. 6 interview code I reviewed. The interviewee is an excellent programmer and also pass one of top 4 companies onsite interview. He showed me how good he is a developer. He was very busy writing code, run test, and keep good presentation. Overall the presentation is so nice.

I never experience such great presentation. I like to learn from his presentation skills. Overall the presentation of his code is perfect. I asked him to test one row and one column, and then he added a few lines of code before the while loop from line 48 to 52.




Being an interviewer: Leetcode 273: Integer to English words

March 24, 2018

Introduction


I have to say that I am a good JavaScript learner. I spent over 6 month full-time at work to learn JavaScript and then rewrote the JavaScript code for my current job back in 2015. One drill I like to do is to follow the peer when I interview on mock interview platform. On March 22, 2018, I had chance to watch how the peer worked on the algorithm using JavaScript.

It is also good learning experience of JavaScript by observing, and asking questions.

Code review


Here is JavaScript code to pass all kinds of test cases.

A few JavaScript features I like to look into:

Keywords:
Eval, const, $, ``,

I like to give the test case for the peer to work on,
let testNum = 1234567890



Friday, March 23, 2018

Leetcode 230: Kth Smallest Element in a BST (Julia 2nd practice)

March 23, 2018

Introduction


It is time for me to work on the algorithm called Kth smallest elment in a BST. I like to write 10 ideas based on the discussion of Leetcode 230.

2nd practice



Leetcode 230: Kth Smallest Element in a BST (Julia 1st practice)

March 23, 2018

Introduction


It is time for me to work on the algorithm called Kth smallest elment in a BST. I like to write 10 ideas based on the discussion of Leetcode 230.

1st practice


I like to write code based on this discussion by yavinci.

Kumon maths

March 23, 2018

Introduction


It is time for me to write a small topic related to Kumon maths. I learned Kumon from my college classmate this week, she showed me how she works hard to solve problems to help her child. Her child got gold medal for math competition in middle school.

Kumon maths


I like to do some research on Kumon maths. Here is one of my favorite articles.


Being an interviewer: Find the 2nd largest element in a binary search tree

March 23, 2018

Introduction


It takes some time for me to learn to be a good interviewer. I start to work on the improvement once I get some ideas how to perform a good interview.

I had a mock interview on March 20 and then I could not understand the code the peer wrote, after 5 minutes discussion, I understood the algorithm. It is so interesting to learn that the peer thinks differently from my understanding of the algorithm.


Code review


Here is Java code I like to review.


Find the 2nd largest element in a binary search tree

March 23, 2018

Introduction


It is my routine to create a gist for the algorithm first. I read the blog about this algorithm called "Find the 2nd largest element in a binary search tree" first on interviewcake.com, and then go over the blog word by word, and try to put together the content in my own words and style.

Here is the gist.


HackerRank NCR code sprint: Spiral Message

March 23, 2018

Introduction


I spent more than 30 minutes to review my own question on stackexchange.com, and I like to post an answer after 15 months. Here is the question I asked in January 2017.

Code review


I wrote the code again, here is the C# code. I will write an answer in short future.

1. change variable names to make it more meaningful.
 startX is changed to rowStart,
 startY is changed to colStart,
 endX   is changed to rowEnd,
 endY   is changed to colEnd.

2. Remove code related to check base cases like one node, one row, one column, set direction variables.

3. Add base case one node and one column break statement just after the first leftmost column.
4. Add base case one row break statement just after the second top row.


My last 3 month practice


The matrix spiral print is my most favorite algorithm, first in January I was interviewed and got low performance 1/ 4 problem solving rating. After that I tried to practice more than 10 ideas using Leetcode 54 discussion panel, I asked the question on stackexchange.com, and then i used the algorithm to interview more than 13 interviewees on mock interview platform. If I do learn something, I must learn from this algorithm.

Here are the links to look up. I still get organized by adding/ modifying the labels on blog platform.

Search by keyword: spiral matrix print, here is the link. Search using keyword: Leetcode 54: Spiral matrix, link is here.


Leetcode 273: Integer to English Words

March 23, 2018

Introduction


I had a mock interview to work on the algorithm called Integer to English words. Since I had a mock interview on March 21, 2018, I visited my friend and did not have a 22 inches monitor to work on. It took me around 40 minutes to work on the algorithm.

It is challenging for me to read small font in the shared editor using my laptop monitor. I get used to read large font and can go over the code quickly using 22 inches monitor.

Being a good interviewer


I also like to advise my peer to learn to be a good interviewer. The interviewer should lead the interviewee to the optimal solution. I did tell the interviewer that I like to work on the solution based on the test case: 1, 234, 567, 890.

Here is my practice in mock interview.

Monday, March 19, 2018

Leetcode 451: Sort Characters By Frequencies

March 19, 2018

Introduction


I have worked on the algorithm including Leetcode 451 as a subproblem so many times called word count practice.

I am so excited to find at least 10 ideas to solve the algorithm. The practice of the algorithm is to train myself using a few algorithms as small as possible, but I like to exhaust all options of the algorithm, get excited to know various approaches, pro and cons. Therefore, I can apply some ideas to the algorithm I have not met before.


Algorithm practice is coming




Thursday, March 15, 2018

Build a new drill for daily workout

March 15, 2018


Introduction


It is easy to stay in the comfortable zone. Specially when I work on the algorithm Knight's tour today, I feel so uncomfortable, I have to deal with an unknown problem, draw a graph, think about problem space, counting sort, seek tips, one after the another. Even though I know that I have to simplify the problem to make it straightforward one. It is called uncomfortable feeling.

In order to push myself out of comfortable zone, I have to develop a drill for myself, work on a new algorithm every few hours in the day time.

How to develop the drill?


I chatted one of computer science graduate student, he just got Google intern offer. He told me that he has worked on Leetcode over 400 algorithms. What I have worked on, less than 150 algorithm from Leetcode.

It is so easy to work on one algorithm. If I take a break every hour, I may just take five minutes break. Read the problem statement of the algorithm using 5 minutes. That is it.

Whenever I have time, I will let myself think about the algorithm.


Need more curiosity?


I need to do some short research how to develop more curiosity on algorithm and data structure. Please list three ideas here.



Knight's tour

March 15, 2018

Introduction


It is very classical dynamic programming called Knight's tour. The problem statement is here on stackoverflow.com.

The most important thing is to know that we only need to count the number of phone numbers, but we do not need to know what numbers for each phone number. The second tip is to know that there are 10 numbers for each step at most.


Algorithm practice


Here is my C# algorithm.

My problem is that it takes me too long to come out the idea and write a solution. I need to make it fit into 20 minutes, 6 to 8 minutes to come out the idea, and I should be able to write the algorithm in less than 10 minutes.


Thinking process


We all know that most important is thinking process. Of course I had long thinking process this time. I drew something on paper, and I took time to think and play with the example.

What I like to do it to make some presentable notes here and document my thinking process. Good thinking process is the gold, the coding part is easy specially for dynamic programming algorithm.

1   2    3

4   5    6

7   8    9

    0

We can tell that 1 can reach 6 and 8. Please check next row and then next column. we denote that knights[1] = new int[]{6, 8}.
Same applies to each number in the first row, next row.

One thing I have to pay attention is number 6, there are 3 numbers to reach, row above, row below, column before, knights[6] = new int[]{0, 1, 7}.

Let us call it first play.

Next play is to work on a graph using those numbers as node, and then connections as edges. It is directed graph as well. Originally in my practice, my drawing is kind of messy. In the following, I try to simplify and make the drawing more readable.

For example, knights[1] = new int[]{6, 8}, I will draw like the following:


0   1    2    3    4   5     6    7    8    9

     ----------------------->

    ------------------------------->


And then we need to add knights[0] = new int[] { 4, 6},

0   1    2     3      4     5    6    7    8    9

------------------->

------------------------------>

We can use depth first search, but time complexity is too high using depth first search. We do not care the path detail. There are so many paths, all we care about the total number of paths.

Once I decide to use a table to store all intermediate result. I have ideas to solve the problem using polynomial time.

Suppose that we start from number 1, and then go over 4 steps and see how many results we can generate.


3              1       3    4     2
2    2   1       1            1
1    0   0   0  0  0 0  1 0  1   0
0    0   1   0  0  0 0  0 0  0   0
-------------------------------------------------
     0   1   2  3  4 5  6  7  8   9

Quora: How do I have a successful road trip 15 days cross the united states?

March 15, 2018

Introduction


It is time for me to celebrate 8 years to land Canada as an immigrant. I like to write a quora article on the topic about 15 days road trip from Florida to the city of  Vancouver.


How to get better on project management?

March 15, 2018

Introduction


I like to try to write something more advanced, like project management. I like to see if I can start to build up some skills to do better project management.

Let us talk about some failures first


I will be back to work on here.


Website project

March 15, 2018


Introduction


It is the five years since I started to write my current company website. Recently I reviewed what I did starting from 2012 and then worked with a few web designers to design and code a website.

I like to write a blog and share my experience how to develop a website first, and then seek ideas to improve the website.






10 good things about mock interview

March 15, 2018

Introduction


I like to write 10 good things about mock interview. I notice that I start to make a lot of changes, I care about the time spent on tennis court, and care about how many things I should purchase. No more cloth shopping, no more phone chat with friends. I am making new connection every day. I am more confident to meet hard working programmers.

It is my short research how the daily mock interview can build up a mediocre software programmer to the top of world, good thinker in algorithm and data structure. It is 12:09 am Thursday morning, I have to prepare to sleep.

It is not my day dream. I also can tell that I do make some improvement and get constant good feedback from my performance on mock interview. I feel so comfortable to do code review in my day time job. I could not believe that I like to rewrite so many things on the website and windows form apps. I even start to like to document my project management activities.

10 good things 


Let me think about more and how to find something subtle in my life, what are those 10 good things?

No. 1:
I do learn one algorithm very well. That is called Sudoku Solver. I have practiced over and over again last 12 months.

No. 2:
I start to learn dynamic programming, and I find that there is a lot of fun.

No. 3:
I start to code every day.

No. 4:
I start to give up some bad habit.

No. 5:

Wednesday, March 14, 2018

The time to make change

March 14, 2018

Introduction


It is so easy to tell that what is my weakness, I need to make change. I have to learn how to plan, analyze what my weakness in order to make some improvement.

Time to make change 


I like to write down three weakness today, and each one I will share a story and hopefully the weakness just reminds me that I am a healthy human being, just need to work on a few basics.

I like to get organized on my github, I have more than one thousand gist with C# practice code. It is very hard for me to browse through those source code now.


A google engineer

March 14, 2018

Introduction


I still remembered that I met an engineer twice on mock interview last December, and then he joined Google.

In other words, I should write a story like this, a future Google engineer coached me two hours how to be an excellent engineer.


Something to remember


I have to review the advice from the peer and then work on one of ideas.



A linkedin intern

March 14, 2018

Introduction


It is hard for me to build connection to outside the world. The first five years from 2010 to 2015 I worked in the city of Vancouver, I rarely had discussion with other software programmers. Starting from January 2015, I started to write coding blog, and then starting from March 2017 I practice mock interview almost daily. I start a new life style to get connected to the world.

What is happening after I practice mock interview? I know so many things and also add more wechat friends from peers I met on mock interviews. More than one month ago, one of my wechat friends met on mock interview shared his linkedin intern offer.


What I can do 


I can celebrate and dedicate one blog to celebrate his hard work. I still remembered that I met him on Christmas day and he showed me how to solve Leetcode 10 using dynamic programming method.


A google intern

March 14, 2018

Introduction


It is good news from one of my wechat friends. Last 4 months I made a few Chinese friends through mock interview and we used wechat to talk since mock interview platform did not work to transfer audio signals.

Yesterday I saw the news about the new Google intern. Such a good news.

What I do 


I have to ask advice how to learn algorithm and data structure from young master graduate student in university of Alberta. I still remembered that he did so well on Array quadruplet using python, he used the idea of two pointer techniques.

We had discussion after mock interview more than half an hour.


Leetcode 120: Triangle

March 14, 2018


Introduction


I find my weakness on the algorithm problem solving. I need to practice a few ideas using Leetcode 120 Triangle to help myself to gain some strength.

First practice 


I chose one of discussion and studied the analysis and C++ code. Here is the gist. I spent a few hours to go over various ideas on the algorithm. I really was so surprised that I knew a few more great programmers in those discussion.



One more practice of Leetcode 133: Clone graph

March 14, 2018


Introduction


It is so sweet to read my last practice on Leetcode 133: clone graph. Here is the coding blog more than 2 years ago.

Let me tell you a secret. When I read my own work two years ago, and then I try to follow what I wrote. It is just sweet feeling, I like the blog much more than the product I write at work. The software I build is to help me make a living, but code in my blog is mine.

This sports teaching of Journal the practice really makes life change. It builds up so rich content for a person to grow as an engineer.

I like to learn one algorithm a time. But it is so surprising to learn so many improvements in my C# code. I could not believe that I am a much better and happy C# programmer these days.

Code practice


Here is the C# code.


Leetcode 133: Clone graph

March 14, 2018

Introduction


It is the good practice to spend time on the discussion and then learn the algorithm.

Discussion


I chose one discussion and studied more than 20 minutes. Here is the gist with the analysis and Java code.


Object-oriented design mock interview

March 14, 2018

Introduction


It is the best gift from the peer in mock interview. I was asked a lot of questions in the mock interview, how to implement a user case? How to define an attacker? It was so exciting and I started to learn from the peer his hard working and his passion to write a game in a few hours.

Also I shared my last 12 months experience, how I will approach the problem and what to look up.


Mock interview 


Here is the transcript for our discussion. The bible teaching is very good on this, do not walk alone, if you fall, the peer may help you to get up.


Object-oriented design review

March 14, 2018

Introduction


It is so exciting to have a partner to work together on the object-oriented design. The peer was very passion and like to apply factory pattern on the design. What an exciting project! Also the project is divided into two parts, version one and version two. We had half an hours discussion in mock interview, and later I received the code.

Code review


I work hard and also like to give some good support to encourage the peer to work hard. So I wrote a code review. Here is my review. I also pasted in the following:

I read your email and also code. Overall I like to see the business rules are defined in your words, and user cases are defined in your function spec. But I am not sure if this practice is old school style. I may be wrong, sorry for my honesty feedback.

You reminded me the elevator simulation algorithm I did last year in the contest. I ended up staying later 4:30 AM.


So here is my coding blog called Hackerrank contest algorithm: elevator simulation.

So here is the discussion panel.

Here is the discussion panel about the algorithm. Every business rule is determined by players as a user case, so we have to define how many user cases in your design, otherwise you will fail test cases.

I like to refer you to those discussion, one of test cases is wrong, then the publisher apologized for the error.

I like to say that it is good idea to get involved in the community like hackerrank contest, some of problems are totally object-oriented design, you have to go through exactly the process of system design, define how to scale, storage, define user cases, and also data structure and algorithm design. There are unknown test cases to pass.

Remember that I may have some hacker spirit, and behave like a warrior borrowed from tennis player Maria Sharapova; that is what I believe and just share with you. I do not worry about too much factory pattern or implementation. Sometimes you know that the job market is so competitive, you cannot expect that the project is waterfall style, you even do not have time to think about the pattern and you have to figure out the business rule you miss and hidden test case you can not pass, how to scale is more important these days, like I did in the contest, staying later up to 4:30 AM to try to score something to improve my ranking, just business-minded and stay aggressive.

That is just my opinion, you can be very intelligent that you are believed that you can apply any pattern you want, if you have time, you have interest, and also you think that it is right thing to do.



Learn the first time Leetcode 333: Largest BST subtree

March 14, 2018

Introduction


It is the first time I learn the algorithm called Leetcode 333: Largest BST subtree. What I like to do is to quickly go over one coding blog about the algorithm, and then spend some time to go over the analysis. I chose the blog since the author wrote down his analysis and it is very helpful for me to understand the algorithm.

I review the analysis in Chinese and then put them in a gist.

Code review


Here is the gist link.

As a programmer, I think that it is more important for me to write down analysis for the algorithm. What I like to train myself is to be able to analyze the algorithm in great detail. Best thing to do is to find a coding blog and then go over word by word.



Leetcode 333: Largest BST subtree

March 14, 2018

Introduction


It is my favorite practice on recursive function again. The algorithm is not available as free one on leetcode.com, and it is called Largest binary search tree's subtree.

Code practice


What I did is to read some coding blogs, and also practiced once as an interviewer. And also I had chance to ask questions and the peer helped me understand the algorithm very well.

Here is my C# practice. Since I do not have chance to run against all test cases, I may think about posting a code review on stackexchange.com. The time complexity is optimal one with O(n) where n is number of nodes in the tree.


Actionable Items


I studied one of coding blogs, and based on the author, there are two more algorithms with O(n2) time complexity. I plan to practice those ideas as well.


Leetcode 365: Water and Jug problem

March 14, 2018

Introduction


It is the most happiest time to learn a few algorithms in a few hours. It is not easy to find time to study a few discussion and then chose to write one of ideas, what I like to do is to put some test cases together and use the test case to help me figure out the algorithm design.

Code practice


Here is my C# practice.


Sudoku solver

March 14, 2018


Introduction


It is my most favorite algorithm in the world. I could not believe that I practiced today with an engineer in Oregon and also I did learn a few things through mock interview. I took extra 30 minutes to discuss with the peer about algorithm practice and exchange ideas. The peer recommended me to practice on codefights.com, consider the purchase of interviewcake.com algorithms with the answers.

I remembered that in 2015 I did study over 5 solution on Sudoku solver algorithm, I spent over 40 hours to practice the algorithm. At that time, I thought that I was the expert on the algorithm. It was so naive and here is the blog link for those practices.

Code practice


I spent less than 10 minutes to analyze the algorithm, and then the peer asked me if I can improve the efficiency to get available numbers to replace '.' char. So I plan to use a hashset to store available numbers.

After I finished the code, I ran the test cases, I only passed one of test cases. So I found out that the hashset should be digits from 1 to 9 excluding those number showing in the same row or column or 3 x 3 small matrix. I just naively got those numbers and put into the hashset instead.

Here is the code. It took me exactly 30 minutes to pass all test cases. I spent around 5 minutes to fix all bugs.


Codefight.com practice

March 14, 2018

Introduction


I got some advice to practice on codefights.com. This is the second time I got advice to practice over there. I will check it out.


Array quadruplet

March 14, 2018

Introduction


It is learning experience to work as a mock interviewer on this algorithm similar to 4 sum. I had the great time to learn and gave some code review on the algorithm.

Code review


Here is C code with my code review from line 62 to line 72.




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#.