Sunday, April 23, 2017

April 23, 2017


Timeout is the big challenge for the algorithm - visiting Manhattan.

Code review 

C# submission is here. Score 7 from 40 points.

Minimum Heap - C# practice

April 23, 2017


A minimum heap C# code is needed for the Email everywhere algorithm in a booking woman in tech contest, so Julia googled and found the C# code. She put together with the algorithm and then she scored 30 points with a full score. Learning to use heap is a great mark for Julia, she knows that completely sorting is expensive, if only max and min value is needed, better to use binary tree, not binary search tree. Julia starts to learn using heap when she work on algorithm problem solving.

Code review 

C# code is here. Need to add some test case and do some code review.

EmailsEverywhere - booking woman in tech

April 23, 2017


It is most rewarding experience to learn and score full 30 points on this algorithm called Email Everywhere. Julia did not have time to practice C# code to write a min heap or max heap using array. She tried so many things but this time she borrowed the code from the internet, and then make it work for the algorithm.

It is a good experience to write brute force solution, and then continued to improve and solve the problems. Look at the submission of the algorithm, Julia learned the min heap and algorithm design through the contest. Well done. Here is the report of submission:

From 2.5 to 4.17, and then 19.17 and then 30 full points, Julia tried to review each step and then write down how she works better next time.

Code review

The last submission with full score 30 is here.

Back to first try, wrong answer and timeout, pass 4 test cases, scored 2.5. Code is here.

Second try, scored 4.17, no more wrong answer. Code is here.

Third submission, scored 19, code is here.

B.Available - Booking woman in tech

April 23, 2017


Code review 

The submission of C# code is here. Score 10.77, maximum score is 60.

Manhattan 2 - booking woman in tech

April 23, 2017


It is most favorite algorithm in the contest. The algorithm is to find the optimal solution using DFS/ BFS, and also need to work on memorization to remove duplicate work, take care of timeout issue.

The problem statement is here.

Julia spent so many hours to work on DFS - recursive function, or using  a stack to do the work. Search the blog using DFS and then a lot of work will be listed here. But Julia worked on in the contest more than 6 hours from 2 pm to 8pm, and she still could not figure out 5 wrong answer test cases.

Algorithm problem solving is such a fun activities. Through those long hours problem solving, Julia now knew so many things she had to learn and work on. This booking contest just let her know that how challenge the work will be if she lands  a job to deal with millions customer.

Code review

The last submission in the contest scored 30 out of maximum score 50. The code is here.

5 runtime error, not timeout.

The submission scored 25 out of maximum score 50, timeout 5 test cases at least. The code is here.

The submission score 23.75, timeout and runtime error. The code is here.

This is the great workout for Julia to learn the algorithm. She replaced recursive solution with a stack, and then she worked on the idea to avoid duplicated calculation. Every node is visited and then sum and maximum value will be recorded, only better candidate can allow to visit again.

From the score 23.75 to 30, Julia worked on the problem solving, understood how important to keep the code as simple as possible. She worked on her last submission to clean up code more than 30 minutes. She learned to discipline herself to show clean and readable code.

Linkedin study - managers and directors

April 23, 2017


It was a beautiful day Sunday and Julia went out for Vancouver sun run. After 10 km running and walking, she was recovering quickly starting from 1:00 pm and then spent more than 60 minutes to study Google managers and directors, facebook managers and directors on linkedin profile.

Julia was noticed that last Friday at work and surprised that she did not pay attention to one of webpage she worked on. She spent over hours to clean up CSS class name and ID selector names, she planned to write a Javascript code to wrap all those data in html code, and then write a simple Javascript array or Json object file to get better organized.

Related to the last Friday work experience and Saturday booking woman tech contest, Julia likes to do a small study about current managers and directors in high tech companies through linkedin.

Study of managers and directors 

Julia does not have a concrete idea what to study and what to look for, she just spent first 20 - 30 minutes to read some managers profiles and then figured out their career path, and then go from there.

She watched the tennis professional players press interviews and also browsed more managers profiles. 

4:08pm 4/23/2017

Rajesh - linkedin profile

Li Fan - linkedin profile

Vanja - linkedin profile

Article about Li Fan is here to join pinterest back to Sept. 2016. Techcrunch article is here about former Google image search director Li Fan joined pinterest in 2016. 3 minutes talk on youtube is here.

Five lessons of scaling pinterest - good time to read an article talking about lessons. Article link is here.

Actionable Items

Watch again press interviews of tennis professional players - learn how to review player, what are the strong player showing in their talk, thought process?

Agnieszka Radwanska - Wimbledon

Garbine Muguruza - semi-final press conference
    Final press conference

   Learn to play free, no fear;
   Mentality - do not like the grass -> like the grass -> it worked.

  French open final after defeating Serena Williams

Maria Sharapova - wimbledon semi-final press conference

 Sharapova is a such a great speaker, and she expressed her idea so impressing and influential.

Friday, April 21, 2017

Booking women in Tech

April 21, 2017


It will be a busy weekend. Julia has to catch up tax return study and preparation this Saturday. She likes to do some study her own on tax issue and visit one of H & R block. But Julia just loves the competition and she likes to experience again the competition.

The contest will have another 30 hours to go. Julia will plan to work on at least 3 - 4 hours this Saturday.

Challenges are here.

Read the article - Learn from the best player - Simran Dokonia, play to win, linkedin profile is here.

Now it is 4:05 pm, April 22, 2017. Julia solved a few problems. Here are the ranking progress report. Julia still has a few hours (15 hours) to work on. Tomorrow morning is Vancouver sun run, Julia has to go to bed early.

Julia felt much better because she is learning from every problem solving. She was busy to work on debugging the code and thinking, such a great workout.

4/23/2017 12:51 am

That is the best I can do. Here is the report:

Follow up after the contest 

1:58 pm, April 23, 2017

Julia read the above comparison, she spent over 860 minutes, almost 14 hours 20 minutes scored 88 points, whereas the 20th only spent less than 605 minutes, around 10 hours to score 245 points.

The 20th player scored extra 157 points from 88 to 245 points, and also spent less than 5 hours compared to Julia.

One thing Julia found out is that players are very consistent on the performance. To compare with top 5% performers, Julia has to catch up more skills - reading, debugging, design of the algorithm and data structure, etc.

Another comparison is here, read Zheng Xu's blog about facebook hacker cup round 2.

Fire code practice website

April 21, 2017

Plan to spend some time to work on Julia was recommended to practice on this website.

Thursday, April 20, 2017

Tax, tax, tax

April 20, 2017


It is a good idea to prepare tax early. Now it is only 10 days before the deadline - April 30, Julia has to push herself to work on tax return.

April 21, 2017, first time Julia has to visit a H&R block in Canada. Get educated and informed about tax laws.

Tax return

Wednesday, April 19, 2017

Recursive function small talk

April 19, 2017


It is a good practice to write down a simple test case, and go over the test case and explain the algorithm, write down every step and every detail to show how you are serious about the talk; show some good analysis by writing down some notes, like mathematical expression, some terms about computer algorithm, and things like pseudo code will be perfect because a person knows recursive function, her writing will terminate because one iteration is enough.

Julia recalled her only experience in 2016 and then she knew that she should write down more transcript instead of code. Try to put 10 minutes in coding writing, first 10 minutes to write down the problem, and everything to ensure the problem is communicated properly, and also the idea will help to lead a bug-free solution.

Julia learned in April after 5 or 6 mocking experience, suddenly she did not scare at all. She likes to play free and use this non-algorithm approach.

Recursive function or DFS algorithm is the most popular algorithm Julia learned to master in 2017.

Recursive function 

Transcript is here to review.

Transcript is being compiled to a new version. Here is the C# code.

Flood fill algorithm small talk

April 19, 2017


Flood fill algorithm is a term Julia learned through wiki article reading in 2017. Julia learned the algorithm through various situations and found out that it is very important to follow the structure to practice. The structure she follows starting less than 1 month is to start from one small example, work through the example. If Julia has 30 minutes to work on the algorithm, she will spend first 10 minutes to work on a small example, go over the problem and think out loud with ideas to solve the problem, write pseudo code, and walk through some test cases. To show the intelligence, Julia will write down something to help herself track the progress. And next 10 minutes to write the code, and 10 minutes for potential issues.

As showed in the following transcript, Julia went through the sample test case, and then counted one by one island and marked them using A, B, C, D, E, F. And then she went over the detail in 10 minutes to write and communicate ideas through her writing. She likes to write and reminds her to go through everything in her preparation to a perfect bug-free coding stage.

Good conversation is like this, Julia said that there is 5 of islands, the peer said that it is six. So Julia just marked one by one using A to E, and then she found F at last moment. It is called cognitive ability, both of players know each other through counting activities. Good warmup. Julia did very well on this, showed that she could collaborate very well, adapt to uncertainty and learn.

Flood fill algorithm 

Here is the 30 minutes transcript in mocking experience.

Julia tried to make the code more clear as possible, and she should push the code to the visit function.

Code review after the practice, fix grammar errors, code is here.

Make the code less verbose, and short. Here is the code to add extract a visit function.

Here is the progress report, the 30 minutes transcript has been worked on to fix grammar errors first, the compiled C# code is optimized to add extract visit function next.

Actionable Item

Read the article one more time, Google hire, write down notes here:

General cognitive ability - the capacity to learn, the combination of raw intelligence

Argument 2:
A diligent interviewer will probe deeply to assess the veracity and thought process - how to do it?

Argument 3:
People who score high on conscientiousness “work to completion”—meaning they don’t stop until a job is done rather than quitting at good enough—and are more likely to feel responsibility for their teams and the environment around them.

App Academy

April 19, 2017


Julia chose a small study topic about app academy to end her busy day, 2 more hours to go. She had a mocking experience tonight at 8:00 pm and wondered how the peer performed so well. And then she found out a new topic for study tonight. The peer went through the training of App Academy. So interesting to know a new academy institution, very creative, 4 months training, no tuition until you find a job in 12 months after graduation, is that cool?

App Academy 

Read 10 - 30 minutes first. App Academy on linkedin is here.

Tuesday, April 18, 2017

Mathematics and hackerrank week code contest

April 18, 2017


It is interesting to know that the advanced algorithm in hackerrank week code contest sometimes is purely a mathematical analysis problem. The score of the algorithm is 100. Julia likes to be able to solve one of them in the short future.

Today Julia likes to study if Euler algorithm on Hackerrank is good choice to practice. Mathematics is a golden mine, if Julia starts to work on the math again, she may find herself to be able to score extra 100 points on hackerrank week code contest.

Based on the experience to work on algorithm "Colliding Circles" in week code 31 contest, Julia learned and practiced one more time how to write clean and efficient DFS algorithm using recursive function. Those 5 hours she experienced a lot to construct a DFS - recursive function.

It was very exciting to make a small change in the two submission, solved test case 4, scored extra 3 points from 8 to 11. Julia learned to be extremely patient to learn to write best recursive code. The experience is documented in this blog.

Here is the short story of reducing time complexity of calculation O(n2) to O(n). There are n balls, any two can collide, so there are total n x (n-1) options; each collide the area gets increment of 2 x ri x rj, sum (2 x rix rj) is O(n x n) time complexity. Since n is 105, so n x n will be 10000 million; time complexity will be lowered from 10000 million of multiplcation to 100000 calculation of summation. As showing in the following code snippet, the difference of two summations is the 3 hours work/ 3 more points, (r1 + r2 +...+ rn)2 - (r12 + r2+ ... + rn2).

More detail please refer to the colliding circles source code line 82 - 87 for extra 3 points. However, using mathematical analysis, the algorithm can be designed with time complexity lower to O(n). It was hard to get it in the contest.

One player did a lot of Euler algorithm heavily recently, the player got mathematics' Ph.D. degree from 1996 to 2000. Julia was wondering if she can learn something from other player's practice.


Those Euler algorithms on hackerrank may be a good place to practice good mathematical problem solving.

Here is the leaderboard Julia tried to study next 30 minutes - 10:06pm - 10:36pm. Who are those talents? What are the motivations to have those talent group? Name 3 of them and try to find motivation behind.

Top player Yuehang Chen - profile is here.
Yuan Li, profile is here.

Take a course - mathematical thinking on coursera by stanford university professor -  keith devlin, or read a book called mathematical thinking.

Cracking the coding interview on hackerrank

I have fought the good fight

Show the first silver medal. And also, read the article about Timothy 4:7 (ESV) “I have fought the good fight, I have finished the race, I have kept the faith.”

Monday, April 17, 2017

Competitive players of week code 31

April 17, 2017


It is a wise decision to study the leaderboard for at least 30 minutes after the contest compared to those long hours to work on contest to get a silver medal day and nights. Julia did like to look into range of 300 - 800 as well, certainly she likes to study those top 300 range.

One of the players shares his blog who score over 200 points compared to 90 points Julia made.

The first one is the second year university student in Zhejiang University, China.

Code blog

Hackerrank profile is here.

Coding blog is here.

Taste like winning

The algorithm is one of advanced algorithm, last one in Hackerrank week of contest 26. Julia did not attend the week of code back to Nov. 2016.

100 points - DP, game theory - Hackerrank contest is the real mathematics, statistics, game theory competition.

The coding blog taste like winning is written in Chinese, and the author talked about his analysis about the algorithm. Quiet interesting! His ranking of week code 26 is 676933.

Hackerrank week code contest 31 small talk

April 17, 2017


It is a very good practice to spend over 5 hours for each hard algorithm in the contest. Julia now has chance to do some research how to improve contest performance,  study how to improve 30% performance to 100% on those two algorithms.

Three algorithms are showed in the following image:

Julia plans to take some time to review those algorithms and then write down small tips to help her to improve.

Study after the contest 

Read one hackerrank player's blog about contest. Link is here.

Sunday, April 16, 2017

Hackerrank: Nominating Group Leaders

April 16, 2017


Problem statement: Nominating Group Leaders

It is the first time Julia spent over 2 hours in the week contest to work on an advanced algorithm in 2017.

2 hours Research 

Julia likes to challenge her research ability to work on an advanced algorithm, and try to come out ideas, simple code, and try to break zero - score any point if she can. At 8:47 pm 4/16/2107, there are over 1095 players score more than 8 points, maximum score is 72.

Follow through the discussion, the brute force will be able to score 8 points. It is not a bad idea to come out the brute force solution first.

Binary index tree

Here is the code review question Julia posted about Hackerrank kindergarten adventure. 

Hackerrank: Colliding Circles (II)

April 16, 2017


It is a good challenging to make some progress on this colliding circles algorithm. Julia spent over 5 hours on this Sunday after church service around 1:30 pm, up to 6:54 pm she managed to make the code work using recursive solution first, and then continued to improve time efficiency. Here is the progress report on this algorithm. At the end of day, the score will go lower after all test cases are run.

It is a good training to learn how to stay calm, and review the time complexity, how to lower O(n*n) calculation to O(n) calculation. Julia tried to get more training on recursive function - DFS search algorithm.

It took Julia more than 6 hours to work on coding and then the algorithm can pass second sample test case and scored 8.78 first time at 4:00 pm this Sunday afternoon. So as a programmer, Julia also liked to be nitpick at her code and then questioned her practice, and then solved test case 4.

So exciting that Julia can bring herself first time in top 10% in the hackerrank contest, she could figure out how hard it takes to get a silver medal.

It is also very good practice to warm up simple probability knowledge when coding this algorithm. Once Julia figured out the probability is important in this algorithm, she started to make points on the algorithm.

Coding is fun 

Julia only has 3 hours left for the contest, she has to finish everything before 10:00 pm. Now it is 7:18 pm. 

Use some bible verse to celebrate the learning of the algorithm, favorite verse from proverbs or psalms. 

Follow up after the contest

April 17, 2017 9:19pm

Code submission is here, score 11.28, extra 3 hours hard work.

First submission with a score is here, score 8 after 5 hours work, score 7.82 out of 65.

Saturday, April 15, 2017

Leetcode weekly contest 28

April 15, 2017

Leetcode 28 weekly Contest webpage

Julia spent 90 minutes to play contest of Leetcode weekly contest 28. She was too busy to read the problem statement and then she never felt that 90 minutes can fly that fast. She just could not believe that she is doing better than week contest 27.

Here is the picture to show some result.

Actionable Items

Try to figure out how to make sense those problem statement on Leetcode, too much wording but Julia could not understand the last 2 algorithm.

Study the leaderboard.

Strategy talk

In the contest 90 minutes, Julia took turns to read last 3 algorithm and could not understand any of them, she did more than 3 rounds, and then she decided to give it a try second algorithm. She understood the math very well and just could not believe that it is a medium algorithm, it is so straightforward, she thought about a lot of ideas at the first.

She was training herself to read problem statement, do not give up, keep reading and thinking, round robin fashion on those 3 algorithms.

Statistics of the contest 

Score is 9, Julia solved first two algorithm in first 80 minutes. Rank is 393/ 1848, score 9's range is  from ranking 170 to 393.

What do you love most about mocking experience?

April 15, 2017


Julia worked on mocking experience starting from April 1, and so far she had 8 experience. What did she like most?

She just checked this video about tennis, what do you like most about tennis. The video is here.

Tennis is last real gladiator sports left.
Even gentle guy likes to crushing experience ...?
Love competition
Atmosphere is just great!
Sound of hitting balls on sweet spot.
What do you like most?

So Julia likes to relate to algorithm and data structure mocking experience, and what she loves most about the experience.

Learn from most talented peers how to perform the problem solving. 

Small talk 

Real fun to go up-and-downs with score, rank from 1 to 7. 
Good experience to journal and then make it better next time. 
Met people and had big surprise how talent people are. 

Let us read some report and get it serious. Understand the performance like sports, win or lose not controllable, understand what is bias and how to fight against odds to show some real work.

Work with people is most difficult part as a software programmer. Julia likes to learn how to work with people and then she can focus on more on technical skills.

Learn to play better mocking experience. One a time.

Facts to remember

April 11, 2017, Know something, Score 1 - "Do not write code until you have a clear algorithm in your head"

In other words, Julia, it is a good idea to write pseudo code first before you write real C# code. Then you can review your algorithm design, clear out any mistakes in thinking process.

Forgot to write base case for DFS algorithm - recursive function in her first writing and then she quickly added it after the reminder. The algorithm is called sudoku solver.

Messed array k step away small talk

April 15, 2017


Julia was busy with Hackerrank week code #31 this morning starting from 8:00 am and she had some issues about her attitude to test cases, last night she stayed up to 1 am to work on coding with test cases. She failed 50% test case of minimum spanning tree, and she thought that this Saturday morning time is the wonderful time to learn how to strength her test skills, she tried to fix those failed test cases today.

Last night 10:00 pm she had a mocking experience but she felt kind of disappointed, because she liked to get more mocking comment. Last night she did not get optimal solution. She could not think freely to reach optimal solution.

But today 10:00 am mocking experience is a very good experience, best of 8 mocking experience. She spent over 10 minutes to work on time complexity analysis, O(k2) -> O(klogk) -> O(k), she stopped before she thought about O(1), she knew that it is not so good to find minimum value using O(k) time. She asked for a hint, and then she was given to think heap sort. She got it right away, O(1) to get the minimum value if minimum heap is used to store k elements. Because all k numbers does not need to be sorted, only minimum value is needed.

Using O(k) time to get minimal is not optimal, use space to trade time, use a binary tree - a data structure to store k element, minimum value is the root of binary tree, that will be O(1) time. Actually it is named minimum heap.

Small talk about messed array 

The 30 minutes mocking experience is here with transcript, thought process, hint given and C# code.

Actionable Item

This is the first time in last 8 experience Julia got rate of 7 for her code. 30 minutes is long time for a conversation. Writing code was to write down what she described in the test case. Even though Julia worked on first 10 minutes without coming out using heap sort, she understood the solution and how to approach the problem by going through a simple test case [1, 2, 3, 4, 5].

"Really familiarize yourself with the sorting algorithms. You definitely understand them but get to a place where you can recall them more intuitively."


The problem is so subtle and then Julia did not come out using heap sort, even though she wrote about the algorithm of search medium using O(1) about a data structure a few days ago. 

Friday, April 14, 2017

Hackerrank: Colliding Circles

April 14, 2017

Problem statement: Colliding Circles

Work on the algorithm.

Plan to spend 2 hours to work on algorithm 4:00 pm - 6:00 pm.


Julia read this comment and try to learn from the sharing.


comment about colliding circles -

5 lines of code - math - combinatorics, full score

recursive - get 10 points

recursive and memorization - get 32.50

Wishful thinking

Stay outdoor and enjoy sunshine and tennis sport this beautiful day in Vancouver - Easter holiday

French Open

What is your first Impact of tennis game?

Impact The Game: What Makes Your Game Unique?

Setting the scene for Roland Garros 2015 feat. Ana, Simona, Jo and Fabio

US Open: Behind the Scenes with Ana Ivanovic, Simona Halep, Jack Sock & Jo-Wilfried Tsonga

Hackerrank: Spanning tree fraction

April 14, 2017


It is a good practice to track the progress, now Julia ranked around 600 at 3:38pm 4/14/2017. She is still working on the algorithm, but she managed to pass some test cases and scored 24.75, first 7 test cases only 0, 1, 2, 6 test cases are passed. The score will be less because there are 7 more test cases.

Here is something she likes to show the progress compared to a Googler:

Right now, she needs to review her code, and read the problem statement a few more times and see if she misses anything important.

Julia likes to work on the next algorithm "Colliding Circles", it is fun and she thought about Combinatorics she learned in her mathematics study. She checked that another googler - yaray scores full score on this colliding circles algorithm.

Follow up after the contest

April 17, 2017 9:11pm

The submission in the contest is here. Failed a few test case, only score 17.68 out of 55.

Kruskal's algorithm workout (I)

April 14, 2017


It is a good workout to work on Kruskal's algorithm based on the article.  Julia likes to spend 2 - 3 hours to play with Kruskal's algorithm using C#. 

Later on, she likes to work on the algorithm on Hackerrank week code 31 - Spanning Tree Fraction. 

Kruskal's algorithm

Greedy algorithm to get minimum spanning tree using Kruskal's algorithm. 

Spent near 2 hours to work on the C# code. C# code is here. 

Thursday, April 13, 2017

Hackerrank: Spanning Tree Fraction

April 13, 2017

Problem statement


Julia likes to work on spanning tree algorithm, even though it is hard algorithm, but Julia did spend some time on the algorithm before. So, it is also a good practice to review previous contests related algorithms.

Julia started to read minimum spanning tree, understand why union set is better than DFS algorithm to detect cycle in the tree algorithm.

Minimum Spanning Tree

Here is the tutorial she studied for the algorithm.
minimum spanning tree -  April 13, 2017 -> graph -> minimum spanning tree -> tutorial 

Kruskal's algorithm - 

Learn the algorithm - using disjoint set / not DFS 

check how it is not connected? Using DFS algorithm to search - O(V + E) 

Value of friendship

Code review of algorithm "value of friendship" is here.

Kruskal's algorithm

GeeksforGeeks article

Code preparation 

Hackerrank zero-one game

April 13, 2017

Problem statement


Julia liked the algorithm very much. She calmed down and worked on the algorithm more than 2 hours.

Here are her submission results. She has to wait until the end of day, the score will go down more since only first 7 test cases are counted.

Here is her report on one of submissions at 9:31pm 4/13/2017:

Follow up after the contest

April 17, 2018 9:08pm

Code submission in the contest, score 24 out of 40, pass 10 of 14 test cases. Code is here.

Hackerrank week code 31

April 13, 2017


Julia learns to stay in the contest and enjoys the hard work to solve some problems. Here is the status at 9:17pm 4/13/2017. Julia compared to the best performer.

Hackerrank Week code 31

It is not easy to  gain any point on advanced algorithm beyond medium algorithm on week of code contest. But Julia found out that she started to learn a few algorithms last 12 months. One of her favorite learning is binary index tree, so much up-and-downs feelings with the learning, but she wrote a very good question kindergarten adventures on code review website. She learned that she should not trust her feelings, it may seem to be difficult, but with calm and systematic way to handle the algorithm, use her strong data analysis experience, no algorithm should be hard. No mountain is too hard to conquer. 

Tuesday, April 11, 2017

Sudoku solver talk

April 11, 2017


Sudoku solver is such interesting problem and Julia wrote more than 3 solution in her practice back in 2015. Here is one of the blogs, and also Leetcode 37: sudoku solver is also very good material to review the algorithm.

Sudoku solver talk 

Here is the C# code written in 30 minutes mocking experience.

Transcript is compiled to make it work. C# code is here.

Highlights of a few corrections:

3 nested for loops. The first 2 for loops is to find the first cell with value -1 to do search, try numbers from 1 to 9 and start a DFS search, if all of them are failed, then return false; otherwise return true.

Need to talk about optimization, use the first one with value -1 to start DFS or other cell?

Daily reading on code review website

April 11, 2017


It is a good idea to read some articles about algorithm every day. Julia chose to follow a few users who reviewed her algorithm questions before.

Here are the list she followed today.

Peter Taylor

Ariano Repetti

Daily reading time

Sunday, April 9, 2017

Find string using slide window - a small talk

April 9, 2017


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

There is a short story about the sliding window algorithm. Julia still remembered that 2 years ago she was asked to solve the algorithm to search a minimum substring, but she failed to solve the problem.

After a week analysis of the algorithm, Julia decided to start to write a coding blog, practice coding every day. She understood that people were helping her to try out the real experience, she was treated nicely even though she had bad performance. She likes to give back to others, shows her generous to share, most likely she will share her failure, struggle at the beginning. She started to write day by day, now her coding blog is like a tree planted by the water that sends out its roots by the stream (Jerimiah 17:8).

Here is the blog about the algorithm to find minimum substring using sliding window technique written 2 years ago.

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

Code review and study 

Julia wrote 30 minutes about an algorithm to search a string using slide window. She likes to code review her algorithm.

C# code is here at the practice, it took 30 minutes to write.

Will work on code more after the practice, here is C# version - revision 1.
Will add some test case to make sure the code is perfect.

Added a test case, debugged the code and found a bug, C# version - revision 2.
line 72 - line 103 - code smells, duplicate logic in if/ else both cases.

4/10/2017 10:28pm
Continue to make code more clean, readable. The code smells in revision 2. Move left pointer loop standalone. C# version - revision 3.

Code Review 

C# code is here at the practice.

Highlights of good things and bad things in the code written in mocking 30 minutes:

1. line 2 - 19 writing of algorithm analysis is very good.
2. line 2 - 19 missing the slide window left point move forward design - skip more than one char
3. line 63 - 65 - this is a bug, for example, unique string "xyz", slide window "xyyz", if next char is x, then "yzx" will be shortest. It is a bug to reset start and end pointer.
4. line 74 - 76 - if statement should be a while loop
    need to add checking whether minimum string is found or not.

Final version after mocking experience is here. C# version - revision 3.

Fully understand the test case first

In order to write good and working code, Julia had to force herself to work on a test case first next time. Here is the test case she worked on April 11, 2017, a few days after mocking experience.

Work on the simple test case again and again, write down the analysis here (4/11/2017):

Find string using sliding window

xyz     xyyzx

Iterate the string one char a time

When to move left pointer? skip two chars in a row - "xy"

xyyzx -> yyzx, remove left pointer, skip x 
yyzx -> yzx,     remove left pointer, skip y

Do one thing a time. 

Every iteration, add the visited char to the slide window, add char to the slide window if it is new, otherwise increase the count. 

Check left pointer to see if it can move forward, make sure do a loop, sometimes it can skip multiple chars. 

Check if slide window contains a string including all unique characters.  

Actionable Items

1. Study the discussion of Leetcode 78.

On the other hand, seeing you find your way out of a difficult situation tells a lot about your character, how you perform under pressure, your ability to think on your feet and your problem solving skills.

1. Not thinking about an algorithm

Make things simpler for yourself. Write down an example on the board and think about just solving that particular instance of the problem by hand.

Small test case -> generalize it back into an algorithm form. 

Julia, please validate the argument. Sounds like true to Julia in 2017.
People tend to bomb their first few sets of interviews. This is mostly because they don’t have sufficient practice with how to handle that pressure of solving an unknown question.

15 mocking interview - systematic way 

Australia Open 2017 - Press conference on and on

April 9, 2017


Coding is a lonely game even Julia worked on code review website and also had mocking experience, sometimes Julia missed the physical experience of tennis sports, people meet on the court and exchange ideas face to face.

Julia has to deal with different emotions when she goes through coding and full time job. She likes to keep learning. One thing she starts to try first time and write a blog is to watch the press conference of tennis player after each round of Australian Open 2017 and document her learning.

Watch one talk a time. Roger Federer had over 5 press conferences. Try to catch up some thinking process of top players, deal with loss, win, emotion, health, practice, everything.

One thing Julia likes to work on is her interview skills, give her a talk, she found out that she is better to learn from top professional players. More real, more related to her reality, she likes to seek open fair opportunity to advance and grow her career, by hard working and showing what she learns through a lot of practice.

Study how players analyzes their game

Roger Federer 

1. Roger Federer Pre-Tournament Press Conference  - 8 minutes

underdog? as long as healthy, have opportunity to play, underdog is fine

2. Roger Federer - SF press conference

3. Final press conference

Play the ball, not your opponent. Problem solving mindset. Play free, brave will be rewarded here. Mindset the coach shared with Roger.

4. After final vs Warinka - Indian Wells 2017 - 15 minutes

Before he has favorite, now enjoy every week. Building block of his career?

Mental challenge? Dubai in lockroom, need more time off before Miami. Lack of energy. From zero, finished middle night. Felt right away, good. Last Nov., Dec., set some goals for season, top 8 in the season. Give me time to get there. Reassess the goal, where is the plan?

Stage of come back? Confidence does wonder. Too much fun, how hard it is to work on. ...

Play vs not play? Play more or less?

Grigo Dimitrov

Grigo Dimitrov - SF press conference


Try to focus on my game when I was in the court. How simple it is that. Cannot control ...

Feel good, compete great! Appreciate my run so far. Give myself a little bit credit.

Talk about loss against Roger, over 4 hours. Great player do, over long hours.

Game plan ....

QF press conference

Stan Wawrinka

SF press conference

CoCo Vandeweghe

CoCo Vandeweghe press conference (SF)

Saturday, April 8, 2017

Leetcode 554: Brick Wall - contest experience

April 8, 2017

Problem statement

Julia spent less than 90 minutes to work on the algorithm in Leetcode week contest 27, from 6:30 pm - 8:00pm. 

Her C# code in the contest is here. Need to work on more on this medium algorithm, Leetcode 554.

Actionable Item

3 medium algorithm, each takes 20 minutes. So, the code should be less than 50 lines for each algorithm.

Time just flies too quickly when Julia worked on Leetcode 554. She managed to work out the sample test case, but it does not pass Leetcode online judge.

Will work on improvements later. 


Julia, you should think about using min heap to track line sweep algorithm, therefore no run time error, which is probably timeout.

Design flaw 

Her C# code in the contest is here.

Time complexity of algorithm Julia implemented, every node is visited more than once at least, upper bound is not sure, some node is visited multiple times; upper bound cannot be determined. 

Better to choose the algorithm only visits each row each brick wall once algorithm, the time complexity is deterministic.

Lesson learned

April 10, 2017 10:00pm

Julia did not notice that her choice of algorithm had timeout issue. The upper bound of the algorithm cannot be determined.

Actionable Item

April 10, 2017
Julia, you over engineering the algorithm. Make it simple and quick.

Julia, you have to measure the algorithm by your engineering power, determine which idea to go for it depending on time constraint. 20 minutes does not allow more than 50 lines of code, bug-free. It is impossible.

April 11, 2017
It should be your routine before you write any algorithm code, try to analyse time complexity.

Leetcode 521: Longest Uncommon Subsequence I

April 8, 2017

Study the article: Longest Uncommon Subsequence 1

Tennis player study - Mirjana Lucic-Baroni

April 8, 2017

Read the article: Journey from Grand Slam title, financial crunch and back.

Wiki article: Mirjana Lucic-Baroni

Leetcode weekly contest 27

April 8, 2017

Plan to play leetcode weekly contest at 6:30 pm. 90 minutes contest.

First time to join the contest.

In 90 minutes, Julia finished first two algorithms, but second one she came int runtime error.

Her C# code in the contest is here. Need to work on more on this medium algorithm, Leetcode 554.

Actionable Item

3 medium algorithm, each takes 20 minutes. So, the code should be less than 50 lines for each algorithm.

Time just flies too quickly when Julia worked on Leetcode 554. She managed to work out the sample test case, but it does not pass Leetcode online judge.

Analysis of Leetcode 554

Julia, you should think about using min heap to track line sweep algorithm, therefore no run time error, which is probably timeout.

Julia's Argument - 2 cents after her first contest 

Leetcode has more fast pace to develop new algorithm and bring into a lot of players compared to Hackerrank, therefore 2017 Julia should spend more time to play with Leetcode algorithm.

Janko NEXT Generation Tour

April 8, 2017


Aging is a great progress, Julia learns how to work with young generation. She also chose to study Janko - how he helped young generation player - a junior player ( 17 years old) to work on ranking 300 to ranking top 100 ATP players. Janko was top 10 player when he gave out his advice to practice with young player, back to 2012.

Video is here. Episode 1.
Episode 2.
Episode 3.
Episode 4.

On The Road to the ATP World Tour Ep. 1

Tie-Break 2/ 5 - coach talk to junior

ATP World Tour uncovered Janko Tipsarevic.

Open court with Janko Tipsarevic

Study how to coach as tennis pro Janko 

Entertainment video

Who has which tattoo?

H tree - a talk about training

April 8, 2017

H-tree is constructed by layers, next layer will start from four corners of H as centers, and the size will be smaller one.

Problem statement - Read this Java implementation from - H-Tree


Julia started to study mocking interview, and see how many things she should work on. Instead of writing a simple recursion version, Julia chose to write a BFS solution using queue. It is a good practice and also showed her passion to write a solution and learned from her mistakes on the mocking.

Training review 

Here is the C# code she wrote in mocking 30 minutes.

Spent over one hour to make the C# code bug-free and code readable.
Also, line 83, correct the calculation of length using square root 2. C# code is here.
Again, make variable names shortest, line 90 - 95. C# code is here.
Things learned in the mocking experience:

1. Julia thought out loud using queue to implement the solution, the interviewer gave out hints to use stack, depth first search;

2. Julia thought about using stack but forgot about recursive function is a natural stack; in other words, using simple recursive function call.

BFS/ DFS difference - DFS can use recursive call, internal stack.

3. Using Queue will work, but the depth should be pushed with queue with center node's information.

4. It is important to stay calm, write instructional code.

Highlight of good/ bad things in mocking experience
(the C# code in mocking experience, good thing is highlighted using brown color, bugs and mistakes are in yellow color):

0. line 1 - 12 work on a H-tree understanding, write a small test case. Understand the H-Tree draw lines, and also requirement of starting length and depth.
1. line 18 - 27, write an internal class Node, define two variables, node and depth.
2. line 22 - 26, Write public constructor of Node class to set up a new node
3.  line 30, Function name is very good - DrawHTreeToDepthUsingBFS
4.  line 30, Function DrawHTreeToDepthUsingBFS's design flaw - return argument should be IList<Node>, not IList<Tuple<int,int>>, missing depth information. Depth information is needed to calculate length of H-Tree.
5. line 29, time complexity is correct? Need to write a recurrence formula first, and then time complexity.
6. line 34 - 37, depth <= 0 will be better
6B. line 39 - syntax error - duplicate new Node(
7. line 41 - Enqueue method - input argument should be variable - node
8. line 43 - adjustLength = depth;  should be adjustLength = startLength, mix length and depth two variables
9. line 57 - 64, should add checking of depth, add H-tree is conditional - major issue
10. line 57 - 60, 4 corners of H, new center node's x, y values are not correct.

Julia, you have to learn from tennis training coach - Janko Tipsarevic - train yourself to be able to write a bug-free, very instructional code. When in real matches, a lot of emotions are mixed with pressures, will to win, anxiety and pressure, you will not notice those mistakes and errors.

Next time, try to write much more slowly, make sure that every line of code is bug-free, syntax ok, no duplicate code.

Through this mocking experience, Julia learned that she still had to practice more on BFS algorithm using Queue, Julia was very comfortable to write and understood that either BFS/ DFS will work out with no problem.

Julia did not have time to go over the code because the peer did not want to wait after 30 minutes.

Also, Julia did not come out using recursive function to write, even after hints. Julia was nervous because she asked help to understand H-Tree with the test case.

Julia likes to show her rigor training through asking over 30 algorithm questions she got from code reviews last 6 months, she is able to write perfect and most modern C# code.

Actionable Items

1. Learn to interview people with different background, technical strength; Learn to write down notes and give out good advice.

2. Do not book more than one mocking a time.

3. Try to improve score of problem solving skills, ratings are low 3 of 7.

4. Take it slow, write instructional code, avoid duplicate code. Using meaningful variable name, function name.

5. Go through up-and-downs through mocking experience, learn to appreciate the time of peer. Try to
manage better the 30 minutes time. Avoid lengthy discussion, be very diplomatic, writing is most important part to show good skills and analysis.

6. Work on a small test case first, this part is very good warmup and prevent bugs in writing and design correctly first time.

7. Make the mocking experience more structured, write down a small test case to understand the problem, show some analysis, and talk about design and choices I may have.

8. All issues Julia had on real experience are reproduced in this mocking experience. Julia, practice more. Do not give up. Write down your feelings, and issues. You will sort it out later.

Friday, April 7, 2017

Leetcode 40: Combination Sum II

April 7, 2017

Problem statement

Log of brainstorm time:

4/7/2017  9:30 pm - 9:40 pm

Leetcode 39: Combination Sum

April 7, 2017


Problem statement

Julia found out that the discussion on Leetcode algorithm generates more than 11.9k views. She decided to study the algorithm again.

Log of study algorithm:

April 7, 2017  9:15 pm - 9:25 pm

Walk through a small test case - median study

April 7, 2017

Problem statement: 

Add 1, 2, 3, 4, 5, and then keep tracking medium value to make sure that it is accessible using time complexity O(1).


Julia teaches herself how to analyse step by step and get into the design of data structure this March 2017. First try, her thought thinking process looks naive from this blog but she likes to write down thought process, and continue to work on it. Life is much easy if Julia chooses to start baby step, reexamine things involved, small talks about every concept which should have been considered in the design process.

Julia likes to spend time on a test case rather than thinking about so many ideas/ articles/ practice she had worked on related to search median algorithm, that is a game to test memory. Instead Julia likes to show a better way, from her training of mathematics courses through her universities - SJTU, FAU math and computer science department, nothing can beat a small example and powerful message of problem solving, it is simple process but it brings out a good thought thinking process - maybe showing great mindset. Time is well-spent on the small test case. 

Baby step talk about data structure design 

Julia likes to practice this to get her familiar with heap concepts and also max heap and min heap.

Here we go.

First 1 is coming, put 1 into left side data structure, she is not sure what kind of data structure should be. 

The median is 1, no problem, just to get the first and only number in left side. 
Left side           Right side

And then, 2 is coming, Julia likes to put Right side.

Left side    Right side
1              2

Median is (1 + 2)/ 2 = 1.5

Now, 3 is coming, we have to decide 3 goes to which side, why? 

Binary search tree vs binary tree

1 2 3, 2 is the medium, we like to keep 2 at the top of data structure, first we decide to let 3 join which side, left or right? 

To allow first number 1 goes to left side, max heap is used for left side data structure. And there is implicit rule, left side data structure saves left half of the numbers, smaller one.

Repeat, middle element is the root of tree, no need to sort, binary tree, smaller half of numbers is in left side data structure. We can make it a max heap.

Rule 1: Left side data structure saves left half of the numbers - smaller ones

Because it is there is no need to sort everything which costs unnecessary time, using binary tree instead of binary search tree, to make median calculation be O(1), we like to keep the middle element at the root of binary tree. 

Left side - Max heap 

So, 1 is smallest value, go to left side, left data structure uses max heap. 
Left – 1
Right -   2

Right side - Min Heap

3, right side is min heap.

Extra rule - left size always not smaller than right side

Keep the left side’s size >= right side

Adjustment - heapify

Move 2 from right side to left side
Left side:  2 1   (starting from root node, and then level by level)

Using array to represent a heap

complete binary tree, 1 2 => node's value is smaller than child's value, swap => 2 1

Right side:  3
The median is 2, since left side’s nodes > right side’s node + 1

Next 4 is coming,  put 4 to right side

Left  side:  2  1
Right side: 3  4

The median is (2 + 3)/ 2 

Next 5 is coming, put 5 to right side because 5 is bigger than left side data structure - max heap's max value

Left side:   2  1
Right side: 3  4  5 

And then move 3 to left side:

Left side:
   2                   3
1   3     =>   1     2

Right side:
  5               4
4     =>    5

Actionable Item

On the other hand, seeing you find your way out of a difficult situation tells a lot about your character, how you perform under pressure, your ability to think on your feet and your problem solving skills.

1. Not thinking about an algorithm

Make things simpler for yourself. Write down an example on the board and think about just solving that particular instance of the problem by hand.

Small test case -> generalize it back into an algorithm form. 

People tend to bomb their first few sets of interviews. This is mostly because they don’t have sufficient practice with how to handle that pressure of solving an unknown question.

15 mocking interview - systematic way 

A note of thankfulness

Julia likes to write a small note to thank Brooklyn to help her on writing better on this blog's introduction section, who is a graduate of linguistic major from university of Victoria in 2015. Brooklyn gave her comment about blog writing in general, and she said that Julia writes very well now.