Tuesday, July 17, 2018

Leetcode 527: word abbreviation

July 17, 2018

Introduction


It is hard level algorithm called word abbreviation. It is the first time I spent time to work on the algorithm. Here is the gist I created for my study.


Leetcode 517: Super washer machine

July 17, 2018

Introduction


It is the hard level algorithm called super washer machine. The idea to solve the problem is kind of interesting. I like to study more later.


Here is the gist I created to help me understand the algorithm and learn an idea how to solve it.


Leetcode 514: Freedom Trail

July 17, 2018

Introduction


Every hard level algorithm deserve me 30 minutes. The algorithm is called Freedom Trail.


30 minutes study


Here is the gist I studied around 30 minutes.


Leetcode algorithms

July 17, 2018

Introduction


I like to spend one hour to go over those Leetcode algorithms. Leetcode 113, 125, 269, 301, 273, 387, 493, 721.




Sunday, July 15, 2018

Tennis WTA coach wim fissette

July 15, 2018

Introduction


It is time for me to study one coach named wim Fissette to help Anger Kerber to win grand slam Wimbledon 2018.

It is something I like to learn from the best coach in the world. I can tell that the coach is so difficult job to do.

A lot of videos to watch


Here is two minutes video, very good one to watch more than once.


Being aggressive was the key

July 15, 2018


Introduction


It is time for me to watch 20 minutes video from Anger Kerber, wimbledon champion. Here is the video link.

Notes


2:00/ 20:00 - Do  not think about too much. What will happen.

2:40 - Come back, without 2017, I could not learn so many things about myself; Make my day schedules. Find motivation after 2016. Such a year is impossible. Try to be a better tennis player, a better person. Try to enjoy the tennis again.

3:52 - She pushed me to the limits. To play final with her, ... Today I had to take the match at my hands.

5:28 - Being aggressive, playing my game.

6:02 - new coach brought about to her. One of keys is to serve good in important moments.

6:49 - play final with Serena. Not thinking too much. Stay cool. Do not show emotions. Going for that. It is not so easy to say. You can do your best.

7:44 - I am 30 years old. So many experience over the years. It helps me to relax. Focus on the match. You have to go through all the things. You have to learn.

10:00 - three grand slam. Play final second time here.

15 minutes break - 7 Can challenges video

July 15, 2018

Introduction


It is time for me to work on reading the book Elements of programming interview. I am kind of needing tea or things to stay alert after more than one hour reading. I like to watch Can challenge video of WTA, 7 videos for my favorite 7 players.

Here is the video link.

First break


It started from 12:40 PM - 1:05 PM, 7/15/2018.

Leetcode 277: Find the celebrity

July 15, 2018

I plan to work on the algorithm at least 30 minutes. I like to get the idea how to solve the algorithm in most time efficient method.


Saturday, July 14, 2018

Two hours coach

July 14, 2018

Introduction


It is so enjoyable to be a coach today on tennis court. I met three young Chinese again in front of tennis wall. I decided to coach two teenagers to play tennis, and also coached a young 23 years old UBC graduate how to play tennis on tennis court.

I have played tennis over five hundred hours and also paid so many coaches for so many private lesson. It is so easy for me to coach the young girl how to adapt tennis footwork, how to walk and run, communicate with the peer etc. It was so much fun for me to be a coach, the workout two hours were so happy and enjoyable.

It is so much fun to work with the young generation. I also talked about my nephew a 24 years old, my sponsor application. Summer time is so much fun to hang out on tennis court.


My six minutes warmup video using medicine ball: Dua Lipa

July 14, 2018

Introduction

It is time for me to find some good video for me to warm up before I go out to play tennis. I found one and also I like to play the video a few times today.

Here is the video link called Opening UEFA Champions League Final.

Summer reading: Elements of programming interview

July 14, 2018

Introduction

It is time for me to start to read the book called Elements of programming interview. I am looking for ways to improve my reading skills.


Summer reading: C++ code is my favorite

July 14, 2018

Introduction


It is so exciting for me to start to go over 500 Leetcode algorithms written in C++. I like to spend next two weeks to read C++ code. What I like to do is to read the problem statement, and then think about five to ten minutes, and read C++ solution.

My summer time bible


I used to call this solution as my bible for next three weeks. I like to go over the solution one by one again. I know that the hard working person will make his code as clean as always.

It is so busy summer time. I like to get some good reading material. Learning C++ from Leetcode solution definitely is also a good style.

Here is Leetcode solution written in C++.


Facebook algorithms

July 14, 2018

Introduction


It is time for me to go over those 70 asked algorithms by Facebook. This time I marked the repository on github.com using star. I like to go over those algorithms again.

One thing I like to do is to go over the notes prepared by this facebook engineer, and see how good she is compared to me. What I can learn from her? The way she organized the document is much better and it is so easy for me to follow her.

One algorithm a time


Here is the link for those algorithms. I like to go over those algorithm this Saturday.


Find a path with minimum maximum value in the matrix

July 14, 2018

Introduction


It is the extended algorithm and binary search algorithm can be applied. The most important is to lower down the time complexity to be controllable. I took the major hint from the mock interviewer and then we had discussion of time complexity. I did learn a lot from this mock interview.

Algorithm discussion


Here is the discussion transcript.


Actionable items


The peer gave me a few advice. Read two books, one is cracking code interview. One is elements of programming interview. And also we discuss how efficient we can do to have mock interview together, how often we can meet. The peer is in Asian country, I am in Canada.

The second advice is to get Leetcode subscription by month, $30/ month. There are a lot of similar algorithms discussed in those paid subscription.

We had discussion about Leetcode algorithm practice. The peer completed around 500 algorithms. But I have around 100 algorithms so far only.

Another discussion is to give each other 10 Leetcode hard level algorithms you have worked on since last meeting. And ask the peer to work on the hard level algorithm one by one in 5 minutes, and then give hint to help if the peer cannot solve. The peer said that it will not work for him.


Lessons learned


When I search the solution, I have to try to find the optimal time complexity as soon as possible. Please have an open discussion with the peer as early as possible. 

What is the brute force solution and time complexity? Can we lower the upper bound of algorithm?

For the algorithm to find minimum maximum value in the path, we have to find the range of value of matrix first, and use it to measure the time complexity of the algorithm. 


Statistics


Meeting time July 14, 2018 9:00 AM PST - 11:10 AM PST

First the peer worked on the infix expression to binary expression tree, and then I worked on the two algorithms, discussion of "Find a path with minimum maximum value in the matrix".


Find a path with increasing value given two nodes in the matrix

July 14, 2018

Introduction


I was given an algorithm to work on called find a path with increasing value given two nodes in the matrix.

10 minutes discussion


Here is the transcript for the discussion. The peer asked me to write code. I told him that I chose not to write code, and go for the extended algorithm.


Clone graph

July 14, 2018

Introduction


I spent 10 minutes to discuss clone graph algorithm with the peer. It takes some time for the peer to understand the requirement. We had discussion, the gist is here.


Infix expression to a binary expression tree

July 14, 2018

Introduction


It is the second meeting with a peer after six months. We met together this January 2018. And then I gave him the algorithm to work on which is to construct binary expression tree using infix expression.

Problem solving


The peer is very strong at coding skills, so he chose the optimal solution linear time O(N), and tried very hard to figure out how to design parsing algorithm using stack.

Here is the transcript how he approached the problem. I can tell that he is very smart on time complexity compared to me.


My feedback


The peer did very good to find optimal solution, try to use stack to parse the string once and build a binary expression tree. The time complexity is O(N), N is length of infix expression. And the peer communicated very well, there are multiple solutions and he decided to push the number and operator to the stack and also build a binary tree node in the same time. Somehow he should think about validation of expression string, and also try to simplify the code. 

Here is my feedback gist.




Statistics


Meeting time July 14, 2018 9:00 AM PST - 11:10 AM PST

First the peer worked on the infix expression to binary expression tree, and then I worked on the two algorithms, discussion of "Find a path with minimum maximum value in the matrix".


Follow up 


July 16, 2018


I wrote C# code to implement the algorithm using O(N) time complexity, N is the expression length. 

Meetup at 7:30 AM

July 14, 2018

Introduction


I had a meetup with the peer this morning at 7:30 AM. I usually did not get up so early. But I did because the peer complained that it is not easy to get mock interview on interviewing.io. I agreed to work with him and work on a few algorithms.

Problem solving

I did not save his code. But I did spend one hour 30 minutes to give him two algorithms to work on. One is to construct binary expression tree using infix expression tree, and the second one is to clone graph.


Actionable Items


I need to learn how to work with people with various background. Sometimes I can tell that peer is so nervous at the beginning because he lacks enough practice.

A friend just reminds me to work hard in the weekend. He originally likes to set up 6:30 AM.




interview advice

July 14, 2018

Introduction


It is good advice I read from a Chinese website written in Chinese. A software developer with more than 5 years experience shares his advice on the onsite interview.

Here is the gist I created. I have to figure out the ways to get good understanding of his advice.

A short version of advice


I like to be creative, fist I copy the note to the current blog and then reorganize it to a short version here.


Friday, July 13, 2018

Infix expression design

July 13, 2018

Introduction


I spent last two days to look into infix expression. I like to know how and why infix expression is designed to allow open and close bracket to help and make it easy to parse using a stack.

I like to google and then find out.

Follow up 

July 14, 2018 10:30 PM

I played tennis today and then I figured out something for my blog on tennis court.

I like to give a good name for this infix expression design.  It is most cheapest way to use extra space to get optimal time complexity.

To design infix expression just uses those extra open bracket and close bracket, cheapest extra space to allow smart programmer to apply linear time to parse the expression, just use a stack to apply the storage for those unprocessed expression.





30 minutes running so fast

July 13, 2018

Introduction


I like to write down some notes about the algorithm I spent 30 minutes to work on. The graph algorithm should be a simple and easy one to write, but somehow I did not test the graph algorithm very well.

I like to spend 10 minutes or so in short future to write down some test cases for a simple graph algorithm.

Clone graph 


I like to study the algorithm called clone graph.

infix expression to construct binary expression tree

July 13, 2018

Introduction


It is my favorite thing to do to scan the code qucikly in less than 15 minutes. Here is C++ for the algorithm.


Using stack


The really important tips are to use stack, so the time complexity can be implemented using O(n) time to parse the infix expression. And the binary express tree can be built in bottom up way. The similar idea using stack can be see in multiple places.

The ) bracket is used to determine when to pop the stack and handle the operand and also operator.


Here is the gist I created how to use stack to parse the infix expression and then construct the binary expression tree.

Here is the output of stack working on a simple test case:

My bet was wrong


 I knew that stack is used on reverse polish notation. And it is widely used to parse the input. There is a hard level algorithm Leetcode 301 to parse parentheses, I did write 10 blogs on that. I also did work on hard level algorithm using more than 10 ideas.

 But the performance on 30 minutes is beyond my control. I could not think clearly using stack and stop on close bracket ), and then start to pop and then construct binary express tree from bottom up.

 What I did is to think about finding operator (1 + 2) so that I can use the string manipulation to get the result. I am not aiming highest potential I can reach in those 30 minutes.

 Through the performance, I understood that it is very important for me to calm down, and list all the options I have. Stack or not using stack, what is time complexity? Can I beat other people to write an optimal time complexity solution.

 I still remembered that I practiced a hard level algorithm on hackerrank and learn the power of using stack. The algorithm is called Reverse shuffle merge.

Actionable Items


Review all past practice using stack.

Here is the first one, Leetcode 109: convert sorted list to binary search tree.

Review one of solution using O(n) time O(1) space, the link is here.



Follow up


Most important is to understand the space is cheap, using space to expedite the time is always best choice, need to scale the problem in large expression. This time I failed to give it a try in 30 minutes using stack to get linear time complexity.

Dua Lipa - See in Blue (documentary)

July 13, 2018

Introduction


It is less than 10 minutes video for me to learn from a singer, what is her thinking process to start her career starting from 15 years old. The video link is here.

I really like the singer and how good she expresses herself using such good statements. Specially a talk related to hard work.

Take some notes




infix to postfix expression study

July 13, 2018

Introduction


It is such a great topic for me to pick up after I spent 30 minutes to write a infix expression parser. I understand that it is so important to lower down time complexity to linear, the only way I can do is to convert to postfix expression, and then I will not need to spend time complexity O(N^2) on the algorithm.

How far I can go on this topic?


There are a few resources I can easily find. I like to choose three good reading material first.





binary expression tree study

July 13, 2018

Introduction


It is called binary expression tree. I really enjoy to spend a few hours on this topic and write a blog to document my study.

Here is the wiki article. I like to spend 10 minutes to read again and write down some notes here.


90 minutes mock interview sharing

July 13, 2018

Introduction


It was my Wednesday 10:00 PM mock interview, I am the interviewer and the peer is very experienced programmer who is preparing facebook onsite interview. He likes to share the interview on mock interview platform, I like to support his decision.

The interview is 90 minutes, 3 algorithms involved. We had very good discussion and I really like the interviewee, he wrote anything I suggested, and I never saw any one wrote so perfect code before.

Website 


There are less than 30 showcases on the site: https://interviewing.io/. Here is the image to help find the mock interview.



Home sick - a song I like to sing

July 13, 2018

Introduction


It is the first time I start to search singers I may like long time. I found one for my summer time, and here is the song called home sick. The singer is Dua Lipa.

I have to find some songs for my tennis workout. I need to work on my summer sports planning and get ready to spend more hours on tennis court.

Here is the song I like to learn next week, and here is the meaning of lyrics of To be the one.




Wednesday, July 11, 2018

What is my motivation to work hard?

July 11, 2018

Introduction


It is a small research topic I did on tennis sports. Professional tennis player and what he/ she believes.

Because one of professional tennis players takes too much time on commercial thing, other professional tennis players think that she will not succeed as other do.

More than 30 minutes chat


I had chat with my friend Emma and we talked about what is my motivation. Do I believe in hard work? Do I believe in luck? or superstitions?

We talked about Carpe Diem, um tatoos professional tennis player put on her hand.




Counting down 48 hours

July 11, 2018

Introduction


I like to train myself this time using 48 hours. I like to go over as many as possible algorithms and data structures in 48 hours range. It is good ideas to go over some Leetcode algorithms, my past practice on hackerrank contest. I like to see the difference this time.

My belief is that using easy level and medium level algorithms to warm up is most efficient way.


Yesterday once more

July 11, 2018

Introduction


I like to use Carpenter song to remind me how sweat the feeling is. Yesterday once more. I got contacted by a very good software company on July 10, 2018.

I documented the birth of my coding blog. Why I started to write coding blogs to help myself starting from January 2015.

Now three years are gone. I have chance to learn something new again. I am so excited.


Graduation season

July 11, 2018

Introduction


It is so enjoyable to congratulate my ex-coach graduated from Tsinghua university master degree yesterday through wechat.com.

I should write something here to celebrate the graduation. Maybe I should copy a few bible verse to make a very good blog here.

Searching ...

Life is a treasure box

July 11, 2018

Introduction


I just could not believe that life is a treasure box. I felt so good to got a message from a peer met more than six months ago. The peer likes to practice with me this weekend on algorithm and data structure problem solving. I just could not believe that he offered me to practice together. He won ICPC region contest before.

I put together a post on github.com. I learn to publish on github.com and see if there are something new to learn. Here is the link.


Count substrings with same first and last characters

July 10, 2018

Introduction

It is the algorithm I am trying to search through Google about contiguous substring. I am  trying to find the optimal solution, but I could not find it. So I decided to study one of post here:

Count substrings with same first and last characters

Tuesday, July 10, 2018

Leetcode 171. Excel Sheet Column Number

July 10, 2018

Introduction


It is an easy level algorithm in Leetcode.com. I plan to review the algorithm quickly.

Leetcode 88: Merge sorted array

July 10, 2018

Introduction


It is an easy level algorithm but I like to practice one more time.

Leetcode 41: First missing positive

July 10, 2018

Introduction


It is a hard level algorithm. I spent 10 minutes to read the solution, and also reviewed my practice this year. I will write down something for the algorithm here.


Leetcode 61: Rotate list

July 10, 2018

Introduction


It is a medium level algorithm called Rotate list. I plan to spend 10 minutes to go over the algorithm in next 24 hours.


Leetcode: Meeting room II - sweep line algorithm

July 10, 2018

Introduction


It is the algorithm called meeting room II. I like to try to use sweep line algorithm to solve the algorithm this time. I will write down something here.


Leetcode 75: Sort colors

July 10, 2018

Introduction


It is the algorithm called sort colors. We can use non-comparison sort, counting sort should be a good solution since we only have three colors.


Leetcode 2: Add two numbers

July 10, 2018

Introduction


It is the algorithm related to linked list. I like to learn how to write a recursive solution, since I like to write a short solution.

Here is the code I read from one of blogs, I like to try it later.

Recursive and iterative solutions


I like to write the code to handle a few test cases in the following order:

1. One of lists is empty;
2. Add one node list together, no carry;
3. Make it work if there is carry, then I need to call the recursive function twice instead of once.

4. Think about how to extend the linked list to more than one node. Add recursive call function.

Here is C# code I wrote using recursive function.

I also spent 10 minutes to review iterative solution written in 2015, and I reviewed the code.

Version of code: 2015  iterative, link is here.
Version of code: 2018  iterative, link is here.

Actionable Items


One way to train myself to write a quick recursive solution is to write a prototype one first. Here is the one I wrote to show how to do it.

Based on prototype function, I just need to add the linked list with more nodes.

I did not think cleary last night since the prototype is more complicated than copy linked list with a random pointer algorithm. Since the prototype already involves one recursive function call.

Monday, July 9, 2018

Enjoy tennis sport

July 9, 2018

Introduction


I just could not believe that I had such great time to play tennis and then I like to spend extra 20 minutes to study a topic to improve my tennis sports.

Here is the post on quora.com I like to study.


Being professional



I also came cross the post how to be a professional tennis player. The talk about being professional is such a great one. I like to copy the talk here.

I like to find some good topics related to summer tennis practice.

Racket sports serve up health benefits.

The Surprising Benefits of Playing Tennis – Tennis Quick Tips Podcast 46

10 hard level Leetcode algorithms

July 9, 2018

Introduction


It is time to say good bye to the weekend. This morning around 10:00 AM I wrote down 10 leetcode hard level algorithms on the paper first, and then I started to work on those hard level algorithms.

What I like to do is to build a good habit to work on hard level algorithms. I have to plan to work on those 10 hard level algorithms in the weekdays as well.

The algorithms are Leetcode 483, 488, 493, 499, 502, 514, 517, 527, 546 and 522.


Alexa.com report

July 9, 2018

Introduction


It is so interesting to read report on alexa.com about my coding blog. Here is the report. Here is the comparison with another popular coding blog with a million view already.

Will continue.

Sunday, July 8, 2018

Alexa - check list for writing

July 8, 2018

Introduction


It is Sunday evening 11:57 PM. I did 10 minutes research and came cross this Alexa.com article. It is called check list for writing.

I like to spend 20 minutes to read the article and write down some notes here.


Leetcode 488: Zuma game

July 8, 2018

Introduction

It is a hard level algorithm called Zuma game. I like to spend 30 minutes to work on it today. Now it is 6:43 PM. I like to spend next 10 - 15 minutes to read the discuss about the algorithm.


Leetcode 483: Smallest good base

July 8, 2018

Introduction


It is the hard level algorithm called smallest good base. I spent 30 minutes to think about problems and last 10 minutes to read discuss. I started from 5:09 PM.


Leetcode 126: word ladder II

July 8, 2018

Introduction


It is the hard level algorithm called word ladder II. I wrote a few blogs in 2016, and I like to review my past practice, and also learn something new.

One of simplified algorithm is only to return one of the shortest transformation sequences.

Have a plan


I like to submit my code using Leetcode online judge this time. I did not submit any code back in 2016, even though I spent so many hours.

I like to check in the code I wrote in 2016 and put into github. I also like to read Leetcode discuss and find out ideas to write simple code this time. Here is C# code link.

Leetcode 129: Sum Root to leaf number

July 8, 2018

Introduction


It is the medium level algorithm called sum root to leaf number. My idea to solve the problem is to pass in prefix sum and use recursive solution. My mistake in my first attempt on sample test case doubles the value from 25 to 50.

Here is my C# code.

Leetcode 295: Find median from data stream

July 8, 2018

Introduction

It is hard level algorithm. I like to review the algorithm using Leetcode online discussion panel.


Leetcode 480: Sliding window median

July 8, 2018

Introduction

It is a hard level algorithm called Sliding window median. I like to work on the algorithm. The optimal time complexity should be O(N), N is the size of the array. How to manipulate the sliding window.

Leetcode 322: Coin change

July 8, 2018

Introduction


The algorithm is medium level. I also wrote an answer on code review more than one year ago. But I have not submitted any answer through online judge.

I am planning to work on the solution and also read some discussion as well.


Backpack problem

July 8, 2018

Introduction

It is time for me to think about the algorithm related to backpack problem. 

m个栈里面有不同面额的硬币,最多pop n次,peek()可以查看任一位置的值,而不仅是最顶的。那么可以取出最多的总值是多少?一开始懵逼了,不知道怎么下手。面试官给我降低难度,只有一个栈的情况,进一步,只有两个栈怎么办? 逐渐觉悟到用递归搜索去解决。按着这个思路代码写出来了。回家复盘的时候,经友人提醒,是多个分组的背包问题


Leetcode 64: Minimum path sum

July 8, 2018

Introduction


It is the medium level algorithm called minimum path sum. I have not submitted any code yet. I like to work on the algorithm in short future. Here is the blog I like to study quickly.


longest subarray with zero sum

July 8, 2018

Introduction


It is Sunday morning. I like to read one of post about onsite algorithms, and work on one algorithm called longest subarray with zero sum.

Ideas 


Two pointers cannot solve the problem. It can be preprocessed all prefix sum from left to right, and then use O(N) time to iterate each element and look up prefix sum with the same value.

What is the possible extended question?


Reference:
1. Onsite algorithms - gist is here.


Saturday, July 7, 2018

Leetcode: Number of islands II

July 7, 2018

Introduction


It is time for me to write code for the algorithm called number of island II. I have warmed up three times on the algorithms, and I like to write one using union-find algorithm.

I tried to give the algorithm number of islands II in my 10:00 PM mock interview. So I had chance to learn more about the algorithm together with the peer.


Blog to study


Here is the blog I like to read. I also will put some notes in Chinese to a gist first.

How to learn to code (quickly and easily!)

July 7, 2018

Introduction


It is very good 11 minutes video related to learn to code.


Languages 


Usually the programmer learns how to write code using a new language by himself/ herself. It is called self-taught.


Why I don't read news

July 7, 2018

Introduction


It is a good research topic related to news value. I like the topic and like to learn something from the talk.

Here is the video's link.

Thing to be considered


What is noise and signal, and try to filter out the information.

10 Year in the life of a software engineer

July 7, 2018

Introduction


I found that it is very good entertainment to see a person can have such freedom to choose to work, travel and have a person life as well. Very good video and very good time to enjoy 10 minutes video.

The video link is here.


How I taught myself to code again (and got a job at Google)

July 7, 2018

Introduction


It is very good topic about teaching and learning to code again. I like the topic. It is 10 minutes video to watch. Here is the link.

Very good thinking process


It is such nice sharing in the forest. I like the sharing.

Computer science fundamental is very important.

Top 3 programming languages in 2018

July 7, 2018

Introduction


I like to spend 20 minutes on this video. It is talk about languages used, top 3 languages can be looked up through the website.


Mock Google interview (for software engineer job) - coding & algorithms tips

July 7, 2018

Introduction


It is 20 minutes video talk and I like to write down some notes. And I also like to study other videos provided by the engineer - Patrick Shyu.

Taking notes from the talk


3:00  Good consideration pros and cons of time and space. Remember show the impact.
Validate a lot of work, craft the story, as soon as some one asks you. Check the interviewer's reaction.

Do not make it too long. Keep it quick. Just 45 minutes. First 15 minutes talking about experience. Next 30 minutes about white board about the algorithm.

5:27
Ask an algorithm on the white board:
Given a grid, find maximum grid. It is commonly asked called flood fill.

How you solve?

Data structure, algorithm and ...

7:12
Tree view, you will be evaluated to have ability to rise a senior engineer level.
You do not have foundation to be a senior level. Tree traversal, and complexity ...

8:20 PM depth first search, double first search (can be BFS), it can be iteratively solved.

Leave it open ended. Grid data structure, 2-D integer.

To a junior, give a start pointer.

10:12  How interesting people can get those neighbors. You have to have a lot of bound check. GetNeighbors, and ..., save your much more time.

Delegate the way to do checking. Hashmap or hashset, what is your hashset. Sometimes you can have a red flag.

12:00 recursive function - 10,000 iteration - how big the grid will be? Push cells to stack or queue.

13:55 Write small font. Bring my own pen.

Tradeoffs, space and time tradeoff


14:42 It should be done before you write the code.

 You need to be able to understand time and space tradeoffs.

Talk about iterative solution vs recursive. At front it is best. We are just coding, we do not know what it is end? Time complexity.

Each cell just once.
16:02 - It is not really you got the answer. Whether you are confident on the answer, how you can do it.

17:25 Experienced interviewer.

Worst time to give the answer of the question.

17:59 Tradeoff between space and time complexity. Evaluation of your code, did you know tradeoff? Did you consider creating data structure? How is your efficiency? How is your jerk? Enthusastic? Take feedback. Overall value skills.

18:03 Your coding good, object-oriented programming. Did you consider using your own data structure?

Friday, July 6, 2018

Code Jam's kickstart

July 6, 2018

Introduction


It is my research task to read Lalit Kundu's quora posts, I spent a few hours to read one by one. I came cross this video talk 30 minutes, and I like to watch the video. Here is the link.

Take some notes


5:00 - 11:00
Talk about solving a problem using a graph. Very good explanation.

11:00 - ?
There is a talk about topological sort algorithm given by Lalit Kundu.

15:13/ 31:55
Some caveats

Not every Kickstart problem will reduce to a known problem or algorithm!
Many problems require creativity and insights
It may help to think through the problem and your algorithm carefully before writing any code

19:57 PM thought process?
So other people's mileage may vary here, do not know what to do right away. Just apply a small individual case and spot some pattern.

Lalit: make it a general form -

20:00/ 31:55 - you can summarize the problem in one statement. Explore certain paths, dynamic programming, greedy algorithm. Good strategy is do not code until you have ideas how to solve it.

I do not code it until I finalize and prove the algorithm.

21:30 It can save you a lot of time to have the correct idea before you write the code.


Quora reading time

July 6, 2018

Introduction


It is time for me to find some good question and answer to read. Here is the one. In order to show support, I also wrote an answer for the question.

My answer


Here is my answer to the question "How can I overcome the difficulties in implementing Data Structures?



Thursday, July 5, 2018

Leetcode 862. Shortest Subarray with Sum at Least K

July 5, 2018

Introduction


It is hard level algorithm. It can be solved using deque, sliding window and O(N) time complexity, N is the array length.


Wimbledon update

July 5, 2018

Introduction


It is the summer time. And it is so important for me to spend time to watch some Wimbledon sports every day.

Day 3 video is here.

Wimbledon grand slam

July 5, 2018

Introduction


It is the summer time and also it is time for me to play sports after the work. I like to spend 20 minutes to watch Wimbledon as well. I like to get more educated on the tournament.




How to decide if the interviewee can go to next round?

July 5, 2018

Introduction


I set up 4 weekdays 10:00 PM as an mock interviewer. I try to get connect to the community and help others to train their algorithm and data structure. I need to work on a few things after I replay and listen to my voice through the conversation. One thing I have to learn is to let more people to go to next round since I use one hard level algorithm to test interviewee, it is hard for a person to solve it in less than 30 minutes first time.

I find so much joy to talk to people and help me to recover from the daily full time work stress last few days. It is so much fun to talk about intern, coding, algorithm, and some tips related to ascending stack technique today.

I will make a check list how to evaluate a peer and decide if I should let him/ her go to next round. I will write down some notes. It is a good study topic for 10 to 20 minutes.

A check list





My second coach

July 5, 2018

Introduction 


I like to write a blog for my second coach this past June, 2018. I was too busy to write a blog about his help and tremendous generous sharing through three mock interviews with me.

Here is the github page I created to document my three mock interviews with my second coach.

863. All Nodes Distance K in Binary Tree

July 5, 2018 I spent 20 minutes to think about the algorithm first, and then plan to read one of discussion article.

Sliding window minimum

July 5, 2018

Introduction


I learn how to give out the mock interview with nice approach. I learned from one of peers giving me feedback, starting from an easy level algorithm and then extending to the hard level algorithm. Let the interviewee warm up on easy level algorithm, and also demonstrate how good he/ she thinks and writes code first. And then it is hard level algorithm if there is need.

I continuously give the same algorithm to people last 5 interviews. I keep coming cross Microsoft programmer or intern from big four companies in the city of Seattle. And also the programmers in the Sillicon Valley. It is easy for me to form a small group for more discussion once a while. I only found one more person to join the small group discussion last one week.

Keep learning


I try to observe myself how I can understand the algorithm by having discussion with different peers. I wrote some hints today. I just keep practice, and work on one thing a time.

Sliding window is most popular algorithm asked in the algorithm interview. It is easy to relate to an array, and also easy to hop on and get some good training on thinking process.

Every time I wrote down some hints.

July 4 10:00 PM - 11:00 PM


July 3, 10:00 PM - 10:50 PM

June 28, 10:00 PM - 10:50 PM

Leetcode spase matrix multilplication group discussion

July 5, 2018

It is our discussion within a group of three people. The time was from 8:30 PM to 10:00 this past Tuesday.

I like to continue to think about this algorithm when I have time. Here is the transcript.


Group discussion

July 5, 2018

Introduction


It is very pleasant to see myself to involve a small group and then we  had good discussion about algorithm together this Tuesday from 8:30 PM to 10:00 PM. This past Tuesday 8:30 PM, we had three people taking turn to discuss one algorithm a time. I had chance to give out an algorithm Jigsaw algorithm and lead the discussion with other two.

Discussion 


I always think about one algorithm last two weeks. I need more challenging thing to do. Last long weekend I worked on seven hard level algorithms. But I still thought about same algorithm again and again. My brain is working this way. So amazing! I better do not waste my energy on the same algorithm. 

Here is the discussion transcript. 

I also like to continue to search and find some interesting to read related to how to design API. 


Actionable Item


It is time for me to do some study about how a person can develop strong interest on algorithm problem solving. 

I used to read mathematics for computer science book. I found that it is very interesting to read. 

How to motivate myself to write 100 lines of code everyday?

July 5, 2018

Introduction


I spent over one hour to write a hard level algorithm called Maximum gap today. I noticed that it is too slow compared to those algorithms I wrote more than 20 times, for example, I can write Sudoku Solver in less than 30 minutes, and I even can remember how many variables I need and how many statements I need to write down, less than 40 lines of code.

I think that I need to train myself to write 100 lines of code against Leetcode online judge every day. There are 128 lines of code for the algorithm Maximum gap including empty line.

If I can write 100 lines of code, and also use Leetcode online judge to train myself to think more carefully about edge cases, I also learn to implement the idea. As a programmer, the most important part is to be able to write perfectly working code in limited time.

Leetcode algorithms


I only submitted Leetcode through online judge for 97 algorithms since 2015. I cannot compete with people with more than 500 algorithm submissions.

Actionable Items


I always think about how to solve jigsaw algorithm recently. One thing I like to do is to ask myself before I write code, can I make my idea more advanced in terms of time complexity, can I scale the problem to millions of row, do I have time out issue or run-out-of-space concern?


Leetcode 864: Random Pick with Blacklist

July 5, 2018

Introduction


It is very good idea to read article related to Leetcode algorithm. The algorithm Leetcode 864 is a hard level algorithm, I had chance to read one of articles.

I will write down something here.

Wednesday, July 4, 2018

Case study: How hard you can train yourself as a software programmer?

July 4, 2018

Introduction


I did study leaderboard of week of code 38 in Canada after the contest last week. I came cross this profile and also his youtube.com channel.

I like to learn from his work. He plays more contest than I do, he also writes a very good blog here.


Tuesday, July 3, 2018

Grigor Dimitrov speaks of his tough first-round loss - Wimbledon 2018

July 3, 2018

Introduction


It is so interesting to watch the interview and I like to learn how to handle the failure. Dimitrov is my favorite tennis sport player.

Good sharing


Stay positive.

4:00/ 11:08 Do not look for excuses.
5:00/ 11:08 Expectation is too high. I could not deal with pressure now. The big pressure is coming from myself.

6:38/ 11:08 Let it sink little bit. I need to calm myself a little bit. Think about rational.

7:57/ 11:08 He is more determined. It is hard for me to accept the losing. It is tough to swallow.

The pigeonhole principle

July 3, 2018

Introduction


It is very popular principle called the pigeonhole principle based on the simple math. I like to study more based on the lecture note written for the maximum gap problem.

The lecture note link is here. And it is also saved on my github.

I like to read the notes carefully and do some research on this pigeonhole principle.


Leetcode 296: Best meeting point

Leetcode 174: dungeon game

Leetcode 164: Maximum gap (Series 1 of 5)

July 3, 2018

Introduction


It is a hard level algorithm called Leetcode 164: Maximum gap. The optimal solution is to use linear time complexity, so the array cannot be sorted using comparison sort. However, if the bucket sort can be applied, and then the array can be sorted using linear time. How do we know the bucket size?

I spent over 20 minutes today to think about the solution. I did think about maximum and minimum value of the array, but what is minimum gap for the array? Can we use the minimum gap to define a bucket? I need those two hints to help me come out the solution.

My practice in 2015


Here are some facts I like to review related to the algorithm.

1. I wrote more than 2 blogs about the algorithm: Leetcode 164: Maximum gap in 2015. Here are the links.
2. I did not submit the code through Leetcode online judge.
I should have submitted the solution.
3. The C# code I wrote could not be found. The gist's link is broken.
4. I spent more than four hours to work on the algorithm in 2015.

My practice in 2018


I plan to write C# code again. It is so exciting to write a hard level algorithm, and understand how important it is to lower down time complexity.

Here is C# code passing online judge.


Monday, July 2, 2018

Job hopping vs Seeking professional development

July 2, 2018

Introduction


It is the long weekend Monday. I stayed at home, and worked on one hard level algorithm, two mock interviews. I had chance to talk to a lead in another country called Spain, and then also I had chat over 15 minutes with a young professional in San Francisco.

The young professional in San Francisco advised me to spend 80% of spare time to work on problem solving skills, as a software programmer, work on algorithm and data structure. You should try to find a good company to allow you to learn advanced frontend technology, but you will be out if your problem solving skills are not so good.

My research topic for the next one or two hours is to understand the article called "Are you job hopping or seeking professional development?". The link is here.

30 minutes study


I like to write down some notes from the article, and I like to understand the ideas as well.

Self-aware  


Statement:
The most effective leaders take the time to develop a practice that enhances self-awareness.

A job-hopping history raises curiosity about whether you know who you are, what you are good at, and where you can make a meaningful contribution.

Smart companies know that self-aware employee are crucial.
  They are better at building relationships with others,
  They are better at managing themselves and creating positive impacts on their environments.
  They often know how to adjust communication to optimize effectiveness.

Experience and curiosity

The trick is to find a balance between curiosity and commitment.

Take the time to think about what you do well and what you enjoy doing most.

Being engaged and productive at work sometimes is the best way for new opportunities to find you.

If you are self-aware, you will notice when these opportunities appear.

My understanding


I do not have psychology degree. This is the first time I read the article and I like to think carefully on those arguments.

The pros and cons of job hopping

July 2, 2018

Introduction


It is a good article to spend 10 minutes to read. The title is called The pros and cons of job hopping.

Pros


Here are the list of pros.

Diverse background.
Access to more information and resources.
Exposure to different businesses and people.
You’ll have a large, resourceful network.
A chance to find the right fit. 
Exposure to different jobs.
An opportunity to show off some of your best attributes.
More money

Cons


Employers will be hesitant to invest in you.
Your job may be less secure
Lack of satisfaction
You may damage relationships
They may question your judgement
They'll fear you'll leave at the first sign of trouble




Here is the truth about how job hopping affects your career

July 2, 2018

Introduction


It is very well written article to read called Here's the truth about how job-hopping affects your career.

10 minutes study


I like to study 10 minutes and then write down a few words, I can look into later.


Career advisor study

July 2, 2018

Introduction


It is time for me to do some study related to career adviser. I came cross this medium article by Larry Cornett.

Eight years on the job celebration

July 2, 2018


Introduction


It is the first time in my career I am able to stay in the same job more than eight years. I just had a great celebration to have a trip to Seattle in June 2018. Also I like to take some short time like 30 minutes or so to study how to manage my career.

How do I spend last eight years? What have I learned as a software programmer?

30 minutes study


Here is one article I plan to spend 10 minutes to read first.

Here is something I like to read first, and then search some keywords in Google.com.

One U.S. boutique firm specializing in IT evaluates candidates on two axes: stability and “performance and capability indicators.” Candidates have to score well on both to be selected for interviews. A consultant at another firm told me that a short stint—less than three years or so—probably wouldn’t be sufficient to produce any meaningful contribution to a firm and thus wouldn’t do much to demonstrate a candidate’s value. Search consultants also tend to interpret frequent moves as a sign of bad decision making, whereas long organizational tenure is rarely seen as reaching a plateau.

A short stint - less than three years or so. 

Search job hopping and then here is another article. 

 “When I see that someone has hopped jobs and gotten increasingly better titles with each new job, it’s a gigantic red flag for me as a hiring manager,” says Souza. “It shows me that they weren’t doing good enough work to get promoted within a single organization, so they had to climb the corporate ladder by continually going somewhere where they have no history.”

Here is the article with a video. 

Leetcode 265: Paint house II

July 2, 2018

Introduction


It is a hard level algorithm called Paint house II. And I like to use this blog to read problem statement.

30 minutes study


Now it is 11:09 AM, I like to spend 30 minutes on the algorithm.

One of ideas is to solve the problem using dynamic programming. At each position of houses, index, it is to get minimum cost to paint each color with color Id.

I notice that greedy algorithm will not work. If every house index the minimum cost is saved without color Id, next time the minimum can not be generated by previous minimum cost. Since we have to compare all colors, the previous one's color id is unknown.

To solve the problem, we have to keep the minimum cost for each index with each color. That is a lot of calculation. Each color ...

I need to get hints to think about simplifying the problem, only keep last two minimum values. Therefore, all colors can be considered for each index position. This is a major hint I need in my thinking process.


Solution study


Here is Chinese version of discussion from the blog:

题解:
是Paint House I的generalized版本。这回颜色不是RGB三种,而是扩展到了K种。正好可以试试在Paint House I中没用上的想法。思路还是使用DP, 这回我们需要维护一个刷当前房子之前所有房子最小的花费min1,以及倒数第二小的花费min2。然后我们再遍历当前房子i所有color的花费,假如这个颜色与之前i-1号房子的颜色相同,我们选择min2,否则选择min1。比较完所有颜色以后我们记录下来当前的curMin1,curMin2以及current color, 更新min1,min2和lastColor,就可以继续计算下一个房子了。
Time Complexity - O(n), Space Complexity - O(1)

Leetcode 262: Trips and users

July 2, 2018

Introduction


It is a hard level algorithm called Trips and Users. Now it is 10:56 AM, I like to spend next 20 minutes to read the problem statement and think about ideas to solve the problem. And then I will spend 10 minutes to find solutions, have a quick study using 10 minutes.

It is my idea to speed up learning process of hard level algorithm. I like to train myself think about hard level algorithms at least 3 of them in a day. One for morning, one for afternoon, one for evening.


Sunday, July 1, 2018

Hard level algorithms - my Canada day

July 1, 2018

Introduction


It is the first time I spent the whole day to go over as much as possible hard level algorithm starting from 11:00 AM to 6:49 PM.

Hard level algorithm


Here are the list. It is not easy to work on hard level algorithms. I did try my best, and focus on getting the ideas first.

Leetcode 97

Leetcode 247 Medium level

Leetcode 248

Leetcode 272

Leetcode 316

Leetcode 327


Actionable Items


It is better to go over hard level algorithm more often, so I can get used to try to solve challenge problem first, sometimes feel good or frustrated. Over the long run, I should feel more confident. It will become part of my daily life. It is like solving Hackerrank contest, I will enjoy the journey.

It is so surprising today I learned another dynamic programming algorithm called interleave string. It is similar to the algorithm called deletion distance.


Leetcode 327: Count of region sum

July 1, 2018

Introduction


It is hard level algorithm called count of region sum. I like to spend 30 minutes on this algorithm first before I go out to play some tennis. I like to spend 20 minutes to read the problem and think about solution first.

Here is the problem statement link.

Now it is 6:28 PM. I spent over 20 minutes to think about it. It may be a dynamic programming solution, and then we try to find all ranges ending at index i, dp[i] stands for the number of ranges in the given range.

Find the solution


It is time for me to find the solution. It is hard for me to come out a complete solution.

It is so exciting to learn something new today.

Here is the idea from one of blogs.

O(n * logn)解法:

解法I 树状数组(Fenwick Tree):
1. 预处理前n项和数组sums

2. 将sums数组离散化(排序+去重)得到数组osums

3. 遍历sums,记sumi = sums[i]
   用二分查找得到[sumi - upper, sumi - lower]的离散化下标[left, right]
   用树状数组统计范围[left, right]内的元素个数,并累加至最终结果ans
   若lower <= sumi <= upper,额外地令ans+1
   将sumi的离散化下标记入树状数组
上述算法将题目转化为下面的问题:
对于数组sums中的每一个元素sumi,统计出现在sumi左侧,并且数值在[sumi - upper, sumi - lower]范围内的元素个数。
这就等价于统计区间和[0, i],[1, i]... [i - 1, i]当中所有落在范围[lower, upper]之内的区间个数。
It is so interesting to read the idea how to solve the algorithm in Chinese. I will do some research and see what I can to solve the algorithm.

解法II 归并排序(Merge Sort):

Leetcode 247: Strobogrammatic Number II

July 1, 2018

Introduction


It is the medium level algorithm. And it is the perfect algorithm to test how to write an elegant recursive solution. It is called strobogrammatic number.

Algorithm study


Here is the blog to provide a recursive solution. I like to write a C# solution as well.


Stroke of Genius: Matina Navratilova

July 1, 2018

I like to play and watch the video a few times called Strokes of Genius: Martina Navratilova Bonus.


Leetcode 248: Strobogrammatic number III

July 1, 2018

Introduction


It is a hard level algorithm called Strobogrammatic  Number III. I like to get into the hard work and spend 30 minutes to work on the algorithm.

I like to read the problem statement and think about using first 20 minutes. Now it is 3:12 PM.

Now it is 3:22 PM. I took some time off. Let me write down something here to help me out, I need to focus on the problem solving.

Problem statement:

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high.

For example,
Given low = "50", high = "100", return 3. Because 69, 88, and 96 are three strobogrammatic numbers.


First 20 minutes of thinking 


I think that there are 3 numbers for first the position, 6, 9 or 8, once it is determined, then last digit is also determined. Brute force solution should just try all options and see if it is in the range.

Time complexity is related to how many possible numbers. We only need to return how many numbers, we do not need to return a list of those numbers.

So we should simplify the algorithm by just check every 10 number, 100 numbers, or 1000, etc. how many possible numbers in total. It should speed up calculation.

Solutions


Now it is 3:49 PM. Let me search the solution. It is not easy to figure out the hard level algorithm. I should read II algorithm first, here is the blog.

Now it is 5:04 PM. I just copied the idea from the blog: http://www.cnblogs.com/grandyang/p/5203228.html

这道题是之前那两道 Strobogrammatic Number II 和 Strobogrammatic Number 的拓展,又增加了难度,让我们找到给定范围内的对称数的个数,我们当然不能一个一个的判断是不是对称数,我们也不能直接每个长度调用第二道中的方法,保存所有的对称数,然后再统计个数,这样OJ会提示内存超过允许的范围,所以我们的解法是基于第二道的基础上,不保存所有的结果,而是在递归中直接计数,根据之前的分析,需要初始化 n = 0 和 n = 1 的情况,然后在其基础上进行递归,递归的长度 len从 low到 high之间遍历,然后我们看当前单词长度有没有达到 len,如果达到了,我们首先要去掉开头是0的多位数,然后去掉长度和 low相同但小于 low的数,和长度和 high相同但大于 high的数,然后结果自增 1,然后分别给当前单词左右加上那五对对称数,继续递归调用.




Leetcode 272: Closest binary search tree value II

July 1, 2018

Introduction


It is a hard level algorithm and also relate to binary search tree. I like to work on it using 30 minutes. Now it is 2:12 PM. First 20 minutes to think about a solution, next 10 minutes to study the solution.

Now it is 2:26 PM. I fount that I had experience to work on mock interview algorithm called next largest successor. I already went through the blog and found one with very good discussion about the algorithm. Here is the blog link.

One idea to use two stacks


I just copied the note from the blog to here:

If we do inorder depth-first traverse (left->root->right) of a binary search tree, we can get an ascending sorted list of elements. If we do reverse inorder depth-first traverse (right->root->left) of a binary search tree, we can get a descending sorted list.
So we create two stacks to store. Stack 1 records the ascending sorted list but it terminates before the element which <= target. (line 40). Stack 2 records the descending sorted list but it terminates at the element which < target. (line 42). (You can also make the first inequality with less than, and the second inequality with larger than or equal to. The main point is that the two stacks shouldn’t contain any element at the same time.)
At last you peek at stack 1 and stack 2. You need to pop element into res list from whichever stack has the top element closer to target.

Leetcode 316: Remove duplicate letters

July 1, 2018

Introduction


It is my second hard level algorithm on July 1 2018 Canada day. It is called Remove duplicate letters. I like to work on the algorithm 30 minutes. Now it is 1:39 PM, I like to work until 2:10 PM.

Remove duplicate letters


Now it is 1:50 PM. I am thinking about using stack to store chars and then I can do backtracking to clean up the stack and put the smallest char in the stack first. Of course I can do some calculation first, count the number for each characters.

Now it is 1:52 PM. Let me check the answer.

One of solutions


Here is the blog I read for the solution. It is similar to the sliding window.



Leetcode 97: Interleave string

July 1, 2018it

Introduction


It is a hard level algorithm called interleave string. I have no idea how to learn a hard level algorithm, I just plan to spend 30 minutes time on this algorithm first. Now it is 12:46 PM, I will end the study at 1:16 PM.

Brainstorming ideas


Now it is 1:07 PM. I like to write down what I thought about in last 20 minutes.

Brute force solution - using linear scan from left to right

Check length to see if longest one is the sum of two small ones.
Count how many chars from a - z and see if the sum of each char equals to the sum of interleave string by characters.
Try to think about go from two ends of the interleave string, and find chars from the two strings to match. There is a recurrence formula.


Now it is 1:12 PM. Let me read one of solutions.

One more thinking,
"a"
"a"
"aa"

"ab"
"a"
think about short string first char position in the longer string, there are how many possible position:
length + 1, check prefix and compare to interleave string's prefix to see if there is a match.


Solution 


1:12 PM - 1:22 PM 10 minutes to study.

I just cannot believe that the dynamic programming method is very similar to Deletion distance.


A good thinker

July 1, 2018

Introduction


It is my Sunday morning research topic. And this is Canada day. I like to choose this topic being a good thinker. This past June I had most important experience of onsite in the city of Seattle in my life, I learn most important thing to be a good thinker of algorithm and data structure.

Strategy of practice


I also like to catch up most important training in my practice. Good thinker, be open to all ideas, and also be careful to start from naive and brute force solution, and search for optimal solution.

I like to work on three hard level algorithms to celebrate 2018 Canada day.

My coach used to tell me that there are so many outstanding people in China and then it was so tough for him to get Google job just after graduating from a master degree. I did study one of players on Leetcode, also I followed his ranking on Hackerrank as well.

It is fun to study those player's performance.

https://leetcode.com/maskray/
https://www.linkedin.com/in/yubowenok/  No. 2
https://leetcode.com/contest/     No. 9

https://leetcode.com/cuiaoxiang/
https://www.zhihu.com/people/cuiaoxiang/activities
https://www.zhihu.com/people/maskray/activities

I like to write more code for Leetcode algorithms this year. Also I like to reduce time to play wechat, and write less on wechat.


Being interviewer: Array index and element equality

July 1, 2018

Introduction


It is the binary search algorithm with extra constraint, lowest index. The peer wrote the algorithm with a few bugs but she showed me how good she did reasoning using test cases at top of the code, two test cases, and she always used them to test her code. This is the first time I saw some one to do that. Very smart and I like to learn it as well.

Binary search algorithm 


Here is the algorithm I helped as a reviewer. I did help to fix the bug, add global variable initialization on line 17.

Being interviewee: Regular expression match

July 1, 2018

Introduction


It was my 10:00 PM mock interview on June 30, 2018. It is my favorite algorithm called regular expression matching, and it is hard level. I have not written any new algorithm in the whole week. The peer did such great job to help me go over the tough thinking process to write code in 40 minutes, and a few debugging to pass 4 out of 6 test cases. After the mock interview, the peer shared with me her Google onsite interview experience and Linkedin onsite experience, so generous sharing. I also learned the lesson to keep practicing.

Dynamic programming one more practice


Here is the code I wrote in mock interview 40 minutes.

I mixed the text string and pattern string. On line 41,

Line 41: else if(currentP == '*' && row >= 2 && text[row - 2] != '*')

The above statement row variable checking should be col >= 2 && pattern[col -2] != '*'

Here are a list of things to slow me down in mock interview:

1. Line 25, write down base case for dynamic programming table first row, when the text string is empty, "b*", ".*", "a*b*" should match empty string.

   The expression can be simplified as well.

2. Line 44 missing pattern[col - 2] == '.' for one or more than one case.

Here is the C# code I fixed the bug after the mock interview.

Binary search algorithm mishap

July 1, 2018

Introduction


It is one of three mock interviews I did on June 30, 2018. I made a mistake to write wrong statement to get rid of half of number, and then I spent over ten minutes to try to fix the bug, since the web compiler shows the return of array is empty.

What I can tell


It is so interesting to observe how I reacted this bug and what I did those 10 minutes. After more than 10 times to work on the algorithm, over 50 times binary search algorithm practice last 6 months.

Stay humble. Stay simple. Also be confident on C# class List.ToArray(), understand better about empty array console output.

Here is the C# code I wrote with a bug on binary search algorithm, and then I ended up adding Console.WriteLine based on the peer's advice. So fun to review the mistake. What a mishap!

Practice is fun



Saturday, June 30, 2018

Leetcode 308: Range sum query 2D - Mutable

June 30, 2018

Introduction


It is also a good idea to work on three hard level algorithm a day, one for morning, one for afternoon, one for evening. There are over 150 hard level algorithms, it is a good idea to stay updated with Leetcode.

One idea I got from the peer before is to read the problem statement first, do not look at the answer, let myself to think about the algorithm at least 20 minutes.

Here is the blog related to the algorithm.

Quick study


It is related to binary index tree. I read the blog 10 minutes, and I also plan to read discussion panel for one or two solutions. That is it.

Here is very good link to read from Leetcode discussion. And then I found a good article to read as well.