Sunday, April 2, 2017

Code practice: analysis of scan document

April 2, 2017

Introduction


Julia likes to practice using LINQ and also learn how to write a C# program. Scan a string and then parse string using delimiters and order by descending order of word's count.

Time complexity analysis: O(Nm), N is the string length, m is the delimiters' length.

Code study 


C# code is here.

Julia reinvented the wheel, write a string.Split(char[]) method. She enjoyed the practice.

Julia need to train herself on LINQ - write statement to query Dictionary and then sort by value using descending order.

Stackoverflow question on LINQ - query dictionary and then sort by value using descending order.

Edge case in SplitMethod()

Actionable Item


Do not stop coding review. Always Julia gets surprising result. Code review this one to celebrate the weekend of first April, 2017.


4 minute coaching of tennis - Janko Tipsarevic

April 2, 2017

Introduction


Julia has to train herself under stress, how to perform algorithm and data structure design. So many emotions will come up, and she has difficulty to do things.

She found herself a coaching lesson - 3 minutes lesson, talking about training, how to stay focus.

Janko Tipsarevic showed his teaching talent - how to focus, work on coaching - forbidding 3 mistakes in a row in the practice.

Coaching video study


Video is here.

Sit on your butt - having a puff?

a mistake hitting to the net - 20 jumps followed.

It is forbidden 3 balls hitting in the net in a row in the forehand swing practice. That is all things you think about. What will happen in your match (1:28 - ) you have all these emotions like fear and anxiety, will to win and line inspect (?) is bad, shit court on the field, what you said last week, there is no light on the court, then you will not think about, (1:46), be aware that you missed. But, here, is forbidden to do it. You should not allow this happen again.

2:43 No matter what I do, only important thing to do is to hit the ball in highest position.

What will happen in the match? So many things in match, so many emotions come up. (2:01 - 3:41)

Actionable Item


Watch more videos from Janko about helping NEXT generation, junior player who had 50 tournaments experience.

Saturday, April 1, 2017

Five qualities small talk

April 1, 2017

Julia chose to do some study about Amazon web service leader Adam Bosworth tonight. She reads one article and then here is her notes.

What would you say to a group of young people looking to enter the tough job market? It doesn't matter what you know. It matters who you are. At the end of day, smart companies hire, promote, and reward employees who demonstrate five qualities:

1. Intelligence
2. Hard work and energy
3. Pragmatism
4. Excellent teamwork
5. The ability to constantly learn new skills and apply everything they've ever learned.

Hackerrank HourRank 19

April 2, 2017

Julia will play hackerrank hourrank 19, and the contest will start from 8:00am PDT to 9:00am PDT. She knows what she should work on in the contest.

Beautiful 
Morning 
Run 

Journey of one hour


Recover the Arrays - 8:00 am - 8:20 am


The hour is very fantastic experience. First 10 minutes to read the first algorithm - Recover the Arrays, and then I asked myself what is missing in the problem statement, Julia missed the statement:

the array's number of elements and then each of elements are followed.

Julia took 10 minutes to figure out this, Julia read the graph with highlighted font "5 2 1" - first char in 3 rows asking herself - what is meaning of the number?

Score 20

What are the Odds?


This is the nim game algorithm. Julia tried to recall the algorithm, she read the problem statement in 10 minutes but could not recall the nim game and current algorithm very well. She has to find how many options, and then she searched her coding blog - Nim, reviewed the algorithm and solution.

Time spent: 8:20 - 8:40 am

The game is modified and she started to read special move before starting a game of Nim.
She tried to think about problem, it should be simple to enumerate all possible selection, and each of them play nim game.

No coding. It is hard to recall the game and it takes time to read through the problem statement.

Maximum Tree Diameter 


Julia decided to give third algorithm some time, from 8:52 am to 9:00 am, she likes to read the problem statement. And she did come out the idea what the problem is.


Actionable Items


Julia checked the third algorithm, how many Google employees played, and then she understood the difference, she has to take life style of those players, if she wants to be a good player.


Beautiful morning run - Julia called this hour a beautiful morning run. She got some companions as well.

Read those minutes, cuiaoxiang even finished 12 minutes before the hour. The first full score was made in the first 31 minutes. Unbelievable!

Julia, you should better invest some time and make the algorithm/ data structure as your powerful weapon. So, it does not matter which job you go to, you will have a good time!

Julia was glad to know that she found her reading challenging through the first algorithm. 10 minutes, she finally understood the algorithm. Based on the experience, in hour rank, Julia will try to work on more to read algorithm problem statement, make sure that she can understand easy algorithm in first reading.

Sports warmup 



Julia's favorite warmup - Sharapova warmup with her coaches 4 minutes video

                                         Angelique Kerber - tennis ball warmup


Tennis Olympics - Andrea Petkovic, Angelique Kerber, Juergen Melzer and many more 4 minutes video.

Algorithm talk - my poor analysis breakdown

April 1, 2017

Introduction


Muscle memory or analysis? Julia learned a lesson and she likes to write down to help herself grow her career. My poor analysis breakdown is to show that Julia tried to control something she has no control, her analysis talent. She built up the talent through practice, but it needs tuned. She learned quickly to dismiss negative feeling and learned to reproduce the issues through mocking experience, later she can overcome the fear and get into zone.

Julia used to work on a lot of assignments for real analysis and abstract algebra, combinatorics course, introduction to cryptography; usually she learned some theorem first, and then try to apply those theorem on the real problems. Proving something is real fun and it takes a lot of discipline.

But mathematics talent is like muscle, you do not use it and then you lose it, based on the fact that "You build muscle, but it becomes fat if you do not maintain it, strength it with sports activity".  Julia likes to find some court to practice her thinking, get some training daily. Therefore, as a software programmer, she can approach hard algorithm carefully and then generate ideas to solve the problem.


Case study 


Will come back after a month to write down when spring season is over. Summer is here.

Hackerearth Easy' 17

April 1, 2017

Julia did not get prepared to attend the contest, she found out the email until last 60 minutes. and then she spent last 40 minutes to work on the contest, she only did one algorithm and read second algorithm. She missed the fun part of struggling and learning.

April Easy 17

Julia will start to build a good habit to attend the contest, 3 hours in Saturday.


Professional tennis player Ana Ivanovic

April 1, 2017

Introduction


Julia read over 100 tennis player wiki pages, a few things she checks every time, prize money and ranking in single and double. And also the player statistics like coaching, how many coaches. She studies players one by one, and then she understands the different styles, strengths, and physical advantage or disadvantage, stage of career.

Julia chooses to learn from a tennis player, formed No.1, retired professional player Ana Ivanovic. She did some study about Ana how she came back from top 50 in last few years in her career. Up and downs, and every player learns so much how to manage her own mind, emotion, and diet, and training.

Algorithm problem solving


Julia did not find her own good personality when to discuss algorithm with a real person, she was suffering big pain because of past experience. She was struggling to deal with mind (emotion of fear of losing) and started to learn how to get into zone issue. Every tennis professional player has to go through the training and understand the sports mental state training, specially top players. It is much fun to learn from the Ana's interview after reading the article.

Julia does not have coaches of her own, and she learns from tennis professional players and their coaches. And she tries to learn from Ana through her career up and downs.

As a matter of fact, no one can solve all the algorithms in the world. Julia should balance her life very well, focus on more how to analyze the problem and compare various ideas to get the optimal one, even pretend to work hard on a small test case in important time will lead to great ideas. For professional tennis players, it does not matter how ugly you play, or how beautiful you have a shot in the sports, at the end of day,  you want to win.

Same thing as algorithm discussion in person, you want to solve the problem, give optimal time/ space algorithm, and then you can score highest, just be yourself.

Last time Julia did not dismiss her nervous when she had to perform on a data structure analysis, so she decides to go back to practice mocking practice one a time.

Study of sports player



Ana talk at Google about mind, training, video is 20 minutes long. 

Julia likes to write down notes, she already watched the videos over 6 times. 


Code Review: binary tree inorder traversal - iterative solution

April 1, 2017

Share the code review:

Binary tree inorder traversal - iterative solution


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

Introduction



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: http://www.tennismindgame.com/zone.html#sthash.RU8u9fFg.dpuf

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

Introduction


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. 


Study 



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

Introduction


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.

Workout


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

 Introduction 


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

Introduction


Julia decided to join stackexchange.com 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

Introduction


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
Answer:
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 ...

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

Answer:
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?

18:32
Question: questions to show problem abilities

Answer:

19:52
Question:  shortlist the C.V.

Answer:

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

22:42
Questions:  problem solver

Answer:

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.

24:00
Questions: Intellectual curiosity
Manager got training to do right assessment

Answer:
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.

27:00
Questions: interviewer training

Answer:

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

32:00
Question:

Answer:

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?

33:00
Question:  background

Answer:

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

Answer:

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 geeksforgeeks.com advised by Pepsi, similar solution to Leetcode 312: Burst Balloon.

Leetcode 312: burst ballons

March 26, 2017

Introduction 


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.


Final


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 populist - Highest scoring answer that outscored an accepted answer with score of more than 10 by more than 2x. 

Hackerrank: Poisonous plant

March 25, 2017

Introduction


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

Introduction

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


Introduction 

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

Introduction

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

Introduction

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

Introduction

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

Introduction

A few things Julia likes about Coding Made Simple on youtube.com. 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

Introduction

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 - codeforces.com

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 geeksforgeeks.com 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.

Introduction


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

Inspiration


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