Wednesday, March 29, 2017

Sports research: Tennis in the zone - 10 ways to Enter the Zone

March 29, 2017

5 More Tennis Drills to help you enter the zone

Sports research: Tennis in the zone - 10 ways to Enter the Zone

March 29, 2017


Julia has to study some topics to help herself. The coding blogger likes to be a top coder, but she has to learn how to solve the easy problem in important time. She is questioning herself in algorithm problem solving, why fear kicks in, she is afraid to tell what she thinks and do not tell at all, or do not warm up and play her skills level.

Julia always looks up tennis sports research and likes to borrows some ideas to help herself.

So she chooses to study "How To Overcome The Fear Of Losing In Tennis" first, and then study "Tennis in the Zone"

Julia likes to solve a problem less seriously using sports research. Millions people like to be top players as a software programmer, Julia has to learn one more step to beat others, that is a mental game. 

Zone study 

The term "the zone" was first used by Mihaly Csikszentmihalyi in his book Flow in Sports.

The zone is that special mental state where everything flows effortlessly and the player is playing at peak performance. James Loehr has called this state the IPS - Ideal Performance State. - See more at:

10 ways to Enter the Zone

1. Challenge and skills 

The player in the zone does not perceive his opponent as a threat. Instead, the player perceives the opponent as a challenge and use his kills to overcome this challenge. A tennis match becomes a problem solving task and the player is focused only on finding the solutions.

Drill: A coach ( or a partner) feeds you balls left and right so that you end up in a defensive position. No opponent.

Next, repeat this drill by playing with your partner and instead of having the idea of playing AGAINST your opponent, focus on solving the problem with each ball. If you solve more than 50% of these challenges, you's win more than 50% of the points, which make you the likely winner.

How to relate to algorithm problem solving?

2. Focus on the process and not on the outcome

The outcome is not within your control. If you focus on the outcome, you will become anxious since deep inside you know that you cannot guarantee the result.

Direction all of your attention toward the ball and what you want to do with it.

Federer does not move his head until he completes the follow-through. This does not mean that he just keeps his head still, it means that he keeps his focus on the execution (an not the outcome - he is not looking at the target area!) and the head therefore remains at the point of contact.

Drill: first image the exact trajectory of the ball - how fast with how much spin...,
another drill is to try to hit the ball in same trajectory as the incoming ball.

3. Having a clear goal and being decisive 

The opposite of being decisive is being indecisive, which means that you don't have a clear goal. A player in the zone does not change his mind and does not doubt his decisions. Whatever decision comes to mind, he sticks with it, trust it, and goes with it.

Drill: Don't attempt to win but try to keep your opponent moving if you are in a good position. Notice how the decision of where to play comes to your mind. When it happens, stay with it. Whatever you decide, stay with it, give it your full attention and don't doubt it.

Even if at one point you realize that another shot might be better, it is too late to replace the old decision with a new one and to reprogram your body for a new shot. You'll only make things worse. So just stay with whatever comes to your mind and execute it with full attention. This is the best way to learn to play instinctively, which is a key component of being in the zone. 

This is new school for Julia! How to relate to algorithm problem solving ideas? 

4. Seeing every shot as feedback

A player in the zone does not judge his shots as good or bad. He sees them only as feedback to indicate whether he needs to keep doing what's working or make slight adjustments. Judgment immediately triggers emotions, which break the flow and the zone state. 

From double ally to whole court, and try to hit the target, learn to read the feedback.

5. Being here and now 

Another characteristic of being in the zone is having no sense of the past or future. The player is immersed in "the now". This allows him to use all of his brain capacity for solving the problem in the moment without distracting thoughts about the past and future. 

Drill: The moment of "now" travels with the moving ball. Rally with a partner and focus your attention on the ball when it's coming to you and the ball when it's going away from you. Notice the seams on it spinning, what color it is, whether you can see the brand (Wilson, Dunlop, etc) spinning, the exact trajectory of the ball, and where it lands. If you devote your full attention to the ball, you'll be in the here and now. You'll also be one step closer to playing in the zone. 

So, Julia, how do you relate to algorithm problem solving, data structure design? 

Actionable Item

Read article about Adam Borsworth

Sports research - How To Overcome The Fear Of Losing In Tennis

March 29, 2017


Julia has to study some topics to help herself. The coding blogger likes to be a top coder, but she has to learn how to solve the easy problem in important time. She is questioning herself in algorithm problem solving, why fear kicks in, she is afraid to tell what she thinks and do not tell at all, or do not warm up and play her skills level.

Julia always looks up tennis sports research and likes to borrows some ideas to help herself.

So she chooses to study "How To Overcome The Fear Of Losing In Tennis" first, and then study "Tennis in the Zone"

Julia likes to solve a problem less seriously using sports research. Millions people like to be top players as a software programmer, Julia has to learn one more step to beat others, that is a mental game. 


Julia likes to learn some new terms and new wisdom through the sports coaching. 

Fear Of Losing And Present Consequences

The negative consequences - your subconscious
You think that you are afraid of losing a match, when you are actually afraid of the consequences of losing a match. 
(Julia, please separate losing a match vs the consequences of losing a match)

How can you solve this mind puzzle? 
Fear of losing and present consequences

Really get into the story of losing a match and how your worst fears come true, like your friends make fun of you, your opponents ridicule you in the locker room, you lose rankings, and so on. 

And then you need to ask two things:

1. What is the probability of this actually happening? 
2. If it happens, can I handle it? Will I survive? Will life go on? 

The first and hardest step in this process is realizing that it is not you doing the thinking: it is the mind

(Julia, sports coaching is fun. First, do one thing: Separate you and the mind first) 

And it is  you who must make a conscious choice whether to follow the thought or dismiss it as unrealistic and unhelpful in achieving your goals.

Losing a tennis match is most likely to be less painful. But you must completely accept the possible consequences if you want to be 100% focused and determined to reach your goal.

The mind can make you view these negative consequences as horrible so that you lose perspective of what "horrible" really is.

When you compare the suffering of these circumstances (blind or paralyzed, no food and shelter) to the suffering you's endure because you lost your #3 ranking and dropped to #7, you see the loss of this tennis match as something you can easily handle.

In other words, just get a realistic perspective on what feeling bad and suffering are.

Your goal is to be 100% sure that you want to play and that you accept the possibility of losing and the consequences that go along with losing. Only then will you be free to play unburdened.

(Julia, please memorize this sentence, like Bible verse.)

Only then will your mind support you and become your ally.

Julia, repeat, your mind support you and become your ally. Your ally is your mind. Julia, ask yourself, when you are nervous, who is your ally? your mind. How to make it one fragile to be a strong ally? take the consequence. Do you want to play unburdened? Yes, I do! 

Read one more paragraph here:
As long as there is a tiny part of you not accepting the negative consequences of losing, you will be nervous and unable to fully concentrate on the match. In other words, some part of your mind will be pulling against you instead of with you in the direction of winning and going for it.

Julia, how tiny part of you not accepting? 1%, 0.01%, Julia thinks about the tiny part of you, how to related to myself in proper way? What to examine? 

Fear of Losing and Past Emotional Pain 

Subconscious pain associated with losing or missing a shot in the past.

This emotional pain stays in your subconscious (since it wasn't resolved), and now any similar event triggers fear of similar pain, which you will try to avoid.

In fact, one of the mind's main purpose is to protect us from pain. It does so by comparing current circumstances to past circumstances that led to pain.

But since you cannot just quit the tournament and you have consciously decided to play it, you mind is now split - you want to play and you don't want to play.

Actionable Item

1. Come back to study again after study of "Tennis in the Zone".
2. Watch the videos:
tennis rank No.11, retired, Ana talk at Google about mind, training, etc.
3. Tennis professional Ana Iva talked about emotional management - anger.

Monday, March 27, 2017

45 minutes workout on a coding blog

March 27, 2017


Julia did know the idea how to do a 45 minutes workout based on powerful search feature of Google. She searched her own blogs using keywords one by one, each one she spends 5 - 10 minutes to read.

Here is her tip to search.
Merge Sort, quicksort, hash function, tree, binary tree, binary search tree, stack, queue, BFS, graph, matrix.


Recursive function is here

Hash function is here

Actionable Items

Julia, you miss the heap, binary tree, non-sorted data structure, etc.  

Sunday, March 26, 2017

Code review: Hackerrank - count string

March 26, 2017


Julia checked the blog stats and then she found out that last week there are over 70 60 views of the blog about Hackerrank: count string. So, she reviewed the 5 blogs related to the study of the algorithm, she quickly reformatted the blogs, and also plans to review the algorithm, and then post a question for code review.

Julia likes to learn something from Google, data driven. So, she makes decision what to review by blogger stats. She reviewed all five blogs related to count string algorithm quickly today, but she needs to reserve some time for a good review on algorithm itself.

Julia wrote 5 blogs in April 2016, this is the first blog. Julia failed to fix the issue to find those 5 blogs using search feature of blog, she worked on labels of those five blogs, somehow, it does not work.

Code review

Theoretic computer science: finding smallest k elements in array in O(k)

March 26, 2017


Julia decided to join theoretic computer science community today. And then she chose one study a time - finding smallest k elements in an array in O(k) time

Julia found out that after more than 24 month heavily working on Leetcode, code review and full time programmer job, she still has not developed the strong analysis of algorithm ability, she evaluated her study on Leetcode 312: balloon burst algorithm on March 26, 2017. It took her more than 4 hours to work on a hard algorithm using dynamic programming, but she still needs more time to play with some test case and figure out something fundamental. So, she decided to find a new school and make the changes.

She decided to join the theoretic computer science community and other communities like Math overflow etc. She likes to find some good thinkers in the computer science, so she can get some training on the analysis - problem solving area. She likes to read algorithms/ articles talking about more about analysis and how to approach a problem.

Algorithm Study 

Surprisingly Julia started to know more computer science theory and graph related scientist, professors and researchers. Cool, Julia likes to read the article with a lot of math formula, she like sto associate with those people who likes to express ideas using mathematical formulas. She feels at home and also like the intensity of learning.

Radu Grigore - spend 10 minutes to read a scientist resume

Google Hiring Best Practices

March 26, 2017


It is 38 minutes video, and Julia likes to review the video again and take down the notes. She likes to know the more by taking notes, google search and come back in the future to review, since Google is hiring right people and is very successful, it makes good sense to learn from the Google. Do you agree?

Her blog about the video in January 12, 2016 is here.

It is not easy task to write down good notes, last time Julia did take notes but after 12 months she had to relearn everything, basically after the study, she did not continue to do any more related study, and she thought that Google is such a far-away-target company to study because she had never experienced anything, like a social event or tech event from Google before January 2017. She does not know that hiring success is leading to Google success.

So, Julia likes to start all over again; and then understand the difference.

Video Study

10:24/ 38:27
How to think, ask, keep asking, keep checking? Like a university, the university may not be a ivy league university.

Check yourself if you are fair, or this person will be super.

11:45/ 38:27
Question:  Panic hiring
panic hiring never never works, take some time to hire/ behavior and hypothetical questions
ask the question from hypothetical question
begin - middle - end, how to check the performance, a lot of following-up question

Argument: behavior question
hypothetical question: you will see the reasoning, you will see the ...

Question: Example of behavior questions
University student, how to approach the thesis

Job specification, people do boolean search, craft the question based on your requirement
Based on what you need, what we launch in UK, how do you approach this?

Question: questions to show problem abilities


Question:  shortlist the C.V.


Huge number of applicants,
Job spec, run test on job spec, if there are a lot of unrelated applicants, then try to use different words in the job spec.

Good C.V., immediately see the impact of the person
Very jumpy, move around a lot; maybe it is ok, bring in to check
Something else jumps to you and are interested.
Entrepreneur, leadership in the resume

Questions:  problem solver


Phone screen, 10 minutes quick check, what they do, and what they are looking for.

Good people know good people.
Networking, get into right events. Recommend people.

Questions: Intellectual curiosity
Manager got training to do right assessment

Life bread, in terms of interview, refresh training
Big training - what are we looking for, criteria
Make people do shadowing interview 2 - 3 times
Give feedback on feedback
What they write on feedback - good analysis - clear analysis - strong enough or not.

Questions: interviewer training


Legal requirement:  UK, 9 months requirement about written feedback
Be very conscious - gender bias on job post
Do not ask personal status, marriage status, religion, and sexual status
Guide away the talk



Students are more likely to try something new. Within interview, you need to learn to sell. Key drive, not just money.

Go for low-hanging food?

Question:  background


Legal requirement to do background checking.

Check Linkedin, company with; before the offer, after the interview, reference check, final exercise.
Phone them, give good references
Area you are related to in.

Google does not use agents.

Question: not working out


Give them fair opportunities.
Senior people review, profile and check.
So much time to get hiring right.

Bring wrong person and so much time to correct them.

Leetcode 218: The Skyline Problem

March 26, 2017

Plan to study the algorithm - Leetcode 218: The skyline problem, hard algorithm

A few steps for the study:

1. Think about the solution by myself first, 20 minutes - 3:08 pm - 3:28 pm
2. Read one of the discussion on leetcode - most popular discussion first - 20 minutes
3. Watch the video of the skyline problem - Coding Made Simple - 22 minutes video

Actionable Items

Julia, you have to work hard. It takes time to work on hard algorithm, just work on one algorithm a time. Focus on thought process, and focus on easy and medium algorithms of Leetcode first.

Do not rush and enjoy the study. Most important skill to acquire is to be able to solve the problem if the hints are given. Be able to respond to hints, and have some reasoning and analysis.

Dynamic Programming - optimal binary search tree

March 26, 2017

Study optimal binary search tree on advised by Pepsi, similar solution to Leetcode 312: Burst Balloon.

Leetcode 312: burst ballons

March 26, 2017


Problem statement

Julia has some difficulty to figure out dynamic programming from the very beginning for unseen problems, so she likes to vote up virtually the analysis of burst ballons on this blog.

The most important message is like the conversation, let us read the sentence by sentence together here.

"This is the kind of problem we use dynamic programming. WHY? it's very challenging to figure out what's the pattern of optimal burst order. In fact, there's no clear rule that makes sense. Shall we burst the balloon with maximum coins? Or shall we burst the one with least. This is the time we introduce Dynamic Programming, as we want to solve the big problem from small subproblem. It is clear that the amount of coins you gain relies on your previous steps. This is a clear signal of using DP.

The hard part is to define the subproblem. Think out what is clear in this problem? Let's scale this problem down. What is the fact you know for sure? Say if the array has only 1 balloon. The maximum coin would be the coin inside this ballon. This is the starting point! So let's move on to array with 2 balloons. Here, we have 2 cases, which of the balloon is the last one. The last one times the coins in boundary is the gain we get in the end. That is to say, last balloon is the key. Since we don't know the pattern of optimal. We just blindly iterate each balloon and check what's total gain if it's the last ballon."

But after those two paragraphs, Julia got lost the formula:

Let's use dp[i][j] to denote maximum gain from balloon range i to j. We try out each balloon as last burst in this range. Then the subproblem relation would be:

foreach k in i to j:
 dp[j][i] = max(array[j-1]*array[k]*array[i+1] + dp[j][k-1] + dp[k+1][i], dp[j][i]);

Algorithm study

Study the blog about burst ballons first. (March 26, 2017, 11:01am - 11:15am)
Watch the video - burst ballons.  (March 26, 2017, 11:15am - 11:30am, 2:40pm - 3:00pm)
Continue to read Leetcode discussion (March 26, 2017, 12:00pm - 12:30pm)

Thinking process

Continue to read Leetcode discussion (March 26, 2017, 12:00pm - 12:30pm)

Julia is getting smarter, she starts to read more discussions from Leetcode discussion instead of blogs written in Chinese, she values the discussion with vote systems.

Discussion with over 400 up-votes - link is here.

Divide and conquer   vs  reverse thinking

Continue to write C# code using sample code (March 26, 2017, 12:30pm - 12:58pm)

Julia's C# practice, pass all Leetcode test cases. Code link is here.

It is not easy to figure out the dynamic programming solution the first time, what I can do is to read the leetcode discussion again, and follow the thought process, from recursive function, naive solution first, and then try to move to next stage.

Notes from discussions:
1. Coursera - algorithm 2 - optimal binary tree DP problem
2. GeekforGeeks algorithm - optimal binary tree DP problem

Thought process rehearsal 

Julia likes to follow up the thought process closely. That is most important part to learn, how to approach the problem naively first, and then move forward with the hints, and problem solving skills.

The most naive idea the backtracking

We have n balloons to burst, which mean we have n steps in the game. In the ith step we have n - i balloons to burst, i = 0 ~ n - 1. Therefore we are looking at an algorithm of O(n!). Well, it is slow, probably works for n < 12 only.

Well, we can find that for any balloons left the maxCoins does not depends on the balloons already bursted. This indicate that we can use memorization (top down) or dynamic programming (bottom up) for all the cases from small numbers of balloon until n balloons. How many cases are there? For k balloons there are C(n, k) cases and for each case it need to scan the k balloons to compare. The sum is quite big still. It is better than O(n!) but worse than O(2n).

Better idea using recursive and memorization or DP

We then think can we apply the divide and conquer technique? After all there seems to be many self similar sub problems from the previous analysis.
Well, the nature way to divide the problem is burst one balloon and separate the balloons into 2 sub sections one on the left and one one the right. However, in this problem the left and right become adjacent and have effects on the maxCoins in the future.
Then another interesting idea come up. Which is quite often seen in dynamic programming (dp) problem analysis. That is reverse thinking. Like I said the coins you get for a balloon does not depend on the balloons already burst. Therefore instead of divide the problem by the first balloon to burst, we divide the problem by the last balloon to burst.
Why is that? Because only the first and last balloons we are sure of their adjacent balloons before hand!
For the first we have nums[i-1]*nums[i]*nums[i+1] for the last we have nums[-1]*nums[i]*nums[n].
OK. Think about n balloons if i is the last one to burst, what now?

We can see that the balloons is again separated into 2 sections. But this time since the balloon i is the last balloon of all to burst, the left and right section now has well defined boundary and do not affect each other! Therefore we can do either recursive method with memoization or dp.


Here comes the final solutions. Note that we put 2 balloons with 1 as boundaries and also burst all the zero balloons in the first round since they won't give any coins.

The algorithm runs in O(n3) which can be easily seen from the 3 loops in dp solution.

Video Study

Watch the video - burst balloons.  (March 26, 2017, 11:15am - 11:30am, 2:40pm - 3:00pm)

19:08/ 27:01

Burst balloons to maximum value, Julia copied and paste from the video:

Saturday, March 25, 2017

Study a code reviewer - Pimgd

March 25, 2017

Plan to study a code reviewer Pimgd and the algorithms related.

48 algorithms

2 algorithms populistHighest scoring answer that outscored an accepted answer with score of more than 10 by more than 2x. 

Hackerrank: Poisonous plant

March 25, 2017


Problem statement

It is hard algorithm under the category of stack. Julia likes the algorithm.

Luigi Vincent, code review profile

Code study

Hacker Rank - Poisonous Plants

How to lose plants and aggravate people

Code Review: Scrabble tile-counting challenge

March 25, 2017

Come back later to review this algorithm. Write down what I like most in this review.

Scrabble tile-counting challenge

Code Review: Implementation of a Card class in Java

March 25, 2017


Julia likes to know when she can be object-oriented programming expert. One thing she can do is to work on a simple class code review, and understand how to make it perfect. Today, she chooses to study this Card class in Java and then get herself comfortable to choose public/ private, static, and name of variable.

Last time when she wrote static for elevator simulation algorithm,  she could not recall when to use static exactly.

Code review study 

Implementation of a Card class in Java

code review study

Code Review: Moving across my (sturdier?) Bridge

March 25, 2017


Julia was short of time and she tried to learn something from Tunaiki before next Monday March 27, 2107. She chose this code review because she tried to figure out how good the user sybOrg is, who asked over 60 questions

Code review study 

Moving across my (sturdier?) Bridge

Code Review: Quicksort

March 25, 2017


Sorting is the most important things in a programmer's life. Julia was so excited to know her first review of quicksort algorithm was chosen as the answer. But she has to keep up learning and makes a wise investment on learning quicksort.

Code review

Integer quicksort in Java

code review: Play a game of Rock, Paper, Scissors

March 25, 2017


Julia likes to work on the object-oriented design, one of her ideas is to post a question on code review for her submission of the algorithm - elevator simulation, but she hold on for some reason. 

Julia came cross this algorithm - play a game of Rock, Paper, Scissors, so she likes to do some study and see how many things can apply to her previous submission of elevator simulation.

Code review study

Play a game of Rock, Paper, Scissors

The Boyer-Moore Majority Vote Algorithm

March 25, 2017


Julia decided to study the code review by a top performer ( 4% of quarter), and she came cross this code review: Finding the candidate with the majority of ballots. And then, Julia recalled that she worked on this kind of algorithm - majority vote last year through facebook code lab. 

Code review study

Read the wiki article - Boyer-Moore majority vote algorithm (March 24, 2017 11:24am - 11:34am)

Study the code review:

The Boyer-Moore Majority Vote Algorithm

Thursday, March 23, 2017

Range minimum Query

March 23, 2017

Plan to read range minimum query wiki article.

Log of history of reading time:

March 23, 2017  8:00pm - 8:20pm   20 minutes

Dynamic programming based range minimum query

March 23, 2017

Code review of dynamic programming:

Dynamic programming based range minimum query

Range minimum query - wiki article.

Algorithm videos - Coding Made Simple

March 23, 2017


A few things Julia likes about Coding Made Simple on Julia saw a lot of numbers written in the lecture, so she is sure that the talk is very detail and making sense on those examples.

Study 1 - 2 algorithms first and then evaluate how good they are.

Algorithm study 

Watch the algorithm lecture video here.

Algorthms: Memoization and Dynamic Programming

March 23, 2017

Study this video 11 minutes 16 seconds produced by Hackerrank.

code review by ranking board neighbor

March 23, 2017


Julia likes to get some good advice on the Java coding experience, one of good shortcut is to read code review in Java more often. She tries to find a good contributor to study from, she checked her performance of quarter 4% and then found her neighbor - Tunaki.

Code review study 

Code review by tunaki.

Julia's favorite algorithm code review:

1. coin change

2. Repeatedly partitioning an array equally as far as possible

3. code review - Julia's C# practice code for Hour Rank 7, Nikita and the Game

4. Find the number of K-Complementary pairs in an array

5. Finding maximum length of continuous string which has same characters -

18 nice answers - more than 10 up-votes

7 time Enlighted badges - First to answer and accepted with score of 10 or more

Stackoverflow links through code review

1. Raw Type in Java -

Actionable Items

Julia could not believe that she found a great mentor on programming.  While she played tennis on central park today, she wondered how come she did not feel tired over 5 or 6 hours to read Tunaki's code review. Usually, in less than one hour, Julia found out something really valuable in the code review.

Sometimes, Julia does not push herself to read code review every day, she is still trying to ask question instead reading answers.

Dynamic programming study

March 23, 2017

Study 50 minutes video - Dynamic programming for programming competitions.

Take some notes:

Fibonacci numbers - Fn = Fn-1 + Fn-2, actually it is exponential formula like 2n, growing quickly.

Wednesday, March 22, 2017

Working at Google - Munich Germany Office

March 22, 2017

Watch the video - 3 minutes 44 seconds.

Small team, high impact.

Engineering driven culture, management is involved and help. It is bottom-up and ...

Motivation is very high.

Snacks is everywhere and it is dangerous to your waistline. Be discipline.

Good, motivated people - initiative and do a good job. No harm in trying.

Meet a Google Associate Product Manager Program Alumna, feat.

March 22, 2017

Watch this video - 2 minutes 34 seconds.

Work with engineer with design, and also commercialization of the product.

Put pages up as you type character - idea?

For every one is like a millisecond, but for a lot of people means years.

Code Jan 2014 Finals in Los Angeles Highlight Reel Google

March 22, 2017

Watch 2 minute 41 seconds video.

What to do -
Advice, find some one is new and also interested. Start from something new, and not stuck on easy bug. And then work on algorithm, work on hard problems.

It is a sports.

Meet an interaction Designer for Google Search

March 22, 2017

Watch the video 2 minutes 38 seconds.

Which direction to push and where to push the product?

Craft, background and technology - 3 things to understand as the technology leader, and then where to push - Alan Eustace, Google SVP in 2013.

Leetcode 417 Pacific Atlantic Water Flow

March 22, 2017

Work on Leetcode 417 Pacific Atlantic Water Flow problem.

Leetcode 274 H-index

March 22, 2017

Work on Leetcode 274 H-index

Study the blog.

Tuesday, March 21, 2017

Algorithm: Longest common seqeuence

March 21, 2017

Go over top 10 algorithms one by one.

Longest common sequence.

1. Read wiki article 20 minutes.

Write down some notes here. Mark your progress to get familiar with wiki article.

2. 30 minutes on university lecture notes

Top algorithms and data structures for competitive programming

March 21, 2017

Read top 10 algorithm advised by 3x Gold medal competitive programmer - Andrei Margeloiu.

Top algorithms and data structures for competitive programming

Monday, March 20, 2017

Algorithm and data structure theory

March 20, 2017

Theory category

Work on blogs to add a category called "theory", Julia likes to go over the theory of algorithm, such as Master Theorem used in merge sort, and other things like "Cyclomatic index", "minimum spanning tree" etc.

MIT algorithm lecture notes - read some of them. 24 lectures notes including peek finding, and edit distance for dynamic programming etc.
Top code tutorials

Geek for geeks top 10 algorithms and data structures

Sunday, March 19, 2017

code review: Hackerrank kindergarten adventures

March 19, 2017

Problem statement

Code review is posted here.

C# code - still work on more test cases on API testing, Modify and Query.


Julia starts to learn binary index tree and segment tree through hackerrank university codesprint #2 in November 2016, she tried a few times but failed each time. She knew that she is better to work on the algorithm "kintergarden adventure" and learn from the algorithm.

She also did post the question on segment tree algorithm on code review to ask help on Dec. 10, 2016, and then the question "kintergarden adventure" was closed. Through the incident, Julia knew that she was afraid to learn by herself.

Julia is very comfortable at data analysis, so in order to figure out the algorithm, Julia chose to have some test case study, put together some data, and then taught herself what to look for through those tables.

Test case study

For example, there are 20000 students in the circle, and the first student only need to 0 minute to finish drawing, so that if the teacher starts from any students from ID = 1 to 20000, the first student can complete the drawing. SegmentTree class Modify API has to take the task to mark those 20000 nodes as value 1, it is not scalable for 3 seconds time limit, so that we can use up to logN intervals to cover the range of [1, 20000].

To make it simple, we assume that the range's width is 1024 instead of 20000, and see how many steps we need to mark in tree[]. Not up to 1024, but in the level of logN = log1024 = 10.

Here is the SegmentTree class Modify API: To understand the test case, in order to modify 1024 nodes as 1, we only do it in less and equal to 10 times, here is the two images to explain the detail.

The two variables of left and right are iterated from beginning to end 10 times, each iteration two variables's values are recorded in the table.

Let us get our hands dirty on this test case, RunTestcaseModify3() line 12, tree.Modify(0,1024,1). We look into the function call.

First row of table, left = 20001, right = 21024, since Modify API is called and function arguments: start = 0, count = 1024, value = 1,
read Modify API code line 5 and line 6, left is calculated as 20001 and right is calculated as 21024.

and more detail is here:

Action items

Review code review Hackerrank Modular Range Queries
Read the tutorial of segment tree.
Learn binary index tree from topcoder


This is the first time Julia started to use Microsoft Excel to do some test case analysis to help her understand the segment tree algorithm design.

All it takes is for her to have some patience. She read those two tables built by Microsoft Excel, and then she asks herself what is missing, what problems she can tell from those data. After a few times search, she comes out ideas to move forward her study.

code review: palindrome

March 19, 2017

Plan to spend 20 minutes to read this code review:

Calculate the number of palindrome numbers in the given ranges

Actionable Items

Study Leetcode algorithms:
Leetcode 347 - Previous practice
LC 417 - Pacific Atlantic Water Flow
LC 247   H-index
LC 402   

Saturday, March 18, 2017

A* algorithm

March 18, 2017

Plan to spend 20 - 30 minutes to read the code review:

A* search algorithm

Leetcode blog - reading is also a good learning

March 18, 2017


Julia knows that she should join the Leetcode discussion as early as in 2015. Now, she knows that her learning style has an important thing to improve, get involved with the community.

When she read the blog of this Leetcode, each one has references from Leetcode discussions. She finds that it is very good blog to read one by one. Most of explanation is written in Chinese, but she will write down notes using English.

Algorithm Study 

Algorithm - Segment tree, lazy propagation

March 18, 2017


Julia likes to invest 30 minutes to study Ahoy, Pirates! algorithm from this competitive programmer through her hackeerank contest experience, she usually studied the players and see what they share. She will find out the profile of Hackerrank and then she can measure how good the player is. Julia did some study on walmartLab codesprint last Oct. 2016 and she documented what she found.

She likes the article written called Advice For Beginners.

Also the writing of article is much better than 80% of Julia's blog. Julia likes the way the author using 3 different colors: purple, blue and red to construct a segment tree and explain the example. A lot of of hardwork, kudo for the author.

Algorithm study - Ahoy, Pirates!

Log of study history

1. March 18, 2017 - 2:14pm - 2:44pm

Good tool to use

Algorithm: All Possible Increasing Subsequences

March 18, 2017


Julia usually does some study after each Hacerrank contest, she mainly looked up the players and see what others are sharing. She will come back to review the blog, and this blog has 23 blogs on algorithm problems.

She likes to invest 20 - 30 minutes on one of algorithms and see how it goes. The time is from March 18, 2017, 1:47pm - 2:10pm. The algorithm is called All Possible Increasing Subsequences.

Read binary index tree wiki article.
Read hackearth binary index tree tutorial. (9:01pm - 9:20pm learn something here!)
Read geekforgeeks Count All increasing subsequences (9:30pm - 9:50pm)

Study one algorithm a time 

1. March 18, 2017, 1:47pm - 2:10pm. (could not focus, move on another algorithm)
2. March 18, 2017, 7:31pm - 8:00pm (mental workout, and try to learn binary index tree)
3. March 18, 2017, 8:00pm - 8:30pm

Summary of study

Not fully understand the algorithm. Move on! Just learn the binary index tree.

Self-balancing binary search tree

March 18, 2017


Julia read this article of binary search, and then she found the article is well-written and also the author brought up a topic called self-balancing search tree. So, Julia will start to read this wiki article, invest 30 minutes first time for the reading.

Article study 

Julia learns to read the wiki article slowly, she knows that in order to be able to give a good reference on codereview, JS1 always referred her to the wiki site. 

Take it seriously, be able to go over the wiki article first, write down new words to learn:


Popular data structures implemented this type of tree include:
2-3 tree
AA tree
AVL tree
Red-black tree
Scapegoat tree
Splay tree


self-balancing tree is the main competitor of hash table, since O(logn) almost good enough for most time efficiency compared to O(1), for example, n = 1000, n is the power of 10.

priority queues - implementation using self-balancing binary search tree
associated arrays -
key-value pairs

Line-segment intersection => sweep line algorithm => Hackerrank: Gridland Metro
Point Location => ?

Are you ready for this statement?
1. self-balancing BSTs have better worst-case lookup performance than hash tables (O(log n) compared to O(n)) <=? making sense?

2. but have worse average-case performance (O(log n) compared to O(1))

Log of reading history

1. Time: 1:11pm - 1:40pm, give 30 minutes for reading, March 18, 2017

binary search - a blog written in Chinese

March 18, 2017


Sometimes Julia likes to read a blog written in Chinese, this binary search article is well-written by a facebook engineer, graduated from Syracuse university. Julia tried to learn more about tail recursion, and a few other things discussed in the article.

Learning is fun, specially in Chinese. Julia will try to choose a few topics in the article and continue to do some research.

Study of binary search 

binary search in "Rotated Sorted Array"

Limitation of array operation, O(1) to look up but O(n) for deletion and insertion

binary search -> work on sorted array -> binary search tree -> self-balanced binary search tree


Time to read a blog written in Chinese- binary search - 30 minutes  ( ended at 1:03pm)
Read the article back and forth 3 times

20 minutes to read self-balanced binary search tree  (start:   end: )

Actionable Item

Read one more blog about management and leadership.

Friday, March 17, 2017

Code review: Longest common substring

March 17, 2017

Think about how to review previous practices on this algorithm, longest common substring.

Study suggestion:

Leetcode 340: longest substring with at most k distinct characters, read this implementation.

Leetcode 271: encode/ decode  - advice from top player.

geek for geek: Find k closest elements to a given value

Wednesday, March 15, 2017

Ask a Google Engineer - How do Innovative Ideas Get Approved at Google?

March 15, 2017

Watch the video 4 minutes 57 seconds, How do Innovative Ideas Get Approved at Google?

Actionable Items

Read facebook engineer Ider Zheng's blogs about how to work on algorithms.
S.O.L.I.D. principle blog.

Ask a Google Engineer - Managers at Google, feat. Fitz and Ben

March 15, 2017

Work on the video - 5 minutes 57 seconds talk, Managers at Google.

First round taking notes 9:50pm - 9:55pm

Do you feel well managed by your superior?

Traditional sense of the world. Traditional management, holdover from industry management, like
an assembly line.

For creative role, solve engineering problem. As a manager, serve you very well.

Move obstacles. Career moves direction.

The place expects you to self-driven. Treat you like an adult. Either you get work done, or you do not.

Micromanagement does not scale. Get next thing need to be done.

Give you trust -

Freedom is your responsibility - something is wrong ......

management culture is pretty cool.

You would be some one's mother. It is like a day care. Have you done your work yet?

Not many command and control.

If you fail, no one to blame.

Ask a Google Engineer - Career Path Working at Google, feat. Fitz and Ben

March 15, 2017

Study the video 3 minutes 6 seconds - Career Path Working at Google.

First round taking notes - 9:42pm - 9:44pm

Five years at Google now.

Never work anywhere more than 4 years. Do something else, more exciting.

Google 4 years come by without noticing. Keep learning, smart and interesting people.

I felt trapped. But in Google there are too many choices, narrow down. It is exciting. Any reason want to leave, too much fun.

It is about people. Mentor and work with them. New point of view. Always learn. Spend time on tech talk, work on design new thing, make things so exciting.

It is written in the textbook. Good culture, ...

Ask a Google Engineer - How to Work at Google: Prospective Employee Qualities

March 15, 2017

Watch a 4 minutes 22 seconds video - How to Work at Google: Prospective Employee Qualities?

Take notes:

First round: 9:24pm - 9:28pm

Two extreme cases:

One got Ph.D., but could not write 5 lines of code.

One works over 20 years on assembly, but forgot all theory he learned.

Google is looking for some one in-middle. Theory in their finger tip, and solid experience to write some good code.

We do not want some one working on something specifically. Look at resume about something generalist, put you in any project, he/ she can do very well.

Skills and experience will be very important. But internet world is a disrupt world.

Play well with others.

Something makes you stand out.

A lot of resumes look the same. Write something showing passion for computer science, or in general.

If this person is a millionaire, he does not need to work. If he is still interested to write some code.

If you are not passion about, you will not write code in your spare time.

Good fit, solid experience, you have done something outstanding.

9:28pm second round taking notes

extreme theory experience     vs    extreme practical experience
Work with some one with passion - need someone to work around

If you are not good at, you will not write code in your spare time.

Come from open source world, ....

Tuesday, March 14, 2017

Algorithms to review

March 14, 2017

Code review 

Julia came cross the coding blog about algorithms today, when she reviewed the quicksort.

She likes to do some research on those algorithms in the blog.

Actionable items:

Read a competitive programmer blog - 23 algorithms
Study the blog - 23 algorithm talks - try to understand 1 -3 algorithms

Code review: algorithms answered by JS1

March 14, 2017


Julia got great code review from JS1, and her most favorite code review is the one called KnightL on a Chessboard. Julia likes to prepare 2 week study, and she thinks that great teacher will educate best stduents. She tries to focus on learning from those algorithms in short future.

Julia knows that best algorithm teacher she has is on code review. Sometimes, she just realizes that her time is so limited and also she needs a mentor. She asked 29 algorithms questions so far, how many are answered by JS1? the number is 6.

Code review study 

Julia plans to read 30 minutes a time about those algorithms:

113 algorithms answered by JS1 - sorted by relevance.

61 program challenged reviewed by JS1.

116 algorithm marked on performance tag

17 C# algorithms

7 dynamic programming

161 Java language implemented algorithm

26 algorithms with time-limit-exceeded

Hacker rank: Journey to the moon

March 14, 2017

Julia decides to follow JS1's code review on algorithms, specially on hackerrank. 

Hacker Rank: Journey to the Moon (Graph Theory)