Monday, September 26, 2016

HackerEarth: algorithm tutorial and problems

Sept. 26, 2016

Julia has some difficulty to handle medium, advanced, hard and difficult algorithm on HackerRank contest world code sprint, so she is actively seeking ways to improve.

Try this one - HackerEarth, at least read each algorithm and find typical problem sets; if need, she can quickly jump into the code. She tries to shorten the time from learning the algorithm to working out an algorithm in 8 hours. So she can compete in the contest.

It is hard to compete in the contest right now, to cover her weakness, she has to dedicate a lot of time for a medium level algorithm. She has to give up weekend sports activities, has to focus on the contest whole weekend, nonstop.

One algorithm a time. One contest a time.

It does not matter how hard Julia has to work on contest, at the end of day - more than 8 hours work, she has to be able to come out a solution for a medium algorithm on HackerRank contest.

The contest problem solving is very similar to the work environment; 48 hours is much better than 24 hours. Julia likes the challenges, she just likes to compete, also she thinks that it is very healthy to compete, so she can improve performance in short time. She could not learn these from the work.

HackerRank is very strict on scoring, therefore, Julia is pushed so hard to bring out her best talent, relentless trial and errors, patiently through 8 hours a time.

Here is the website:

Recommended by

HackerRank - World code sprint #7 - summary

Sept. 26, 2016
Good news! A bronze medal! Top 25%.

  It was a busy weekend, Julia spent over 10 hours a day on algorithm problem solving, scored 67.81, ranked 737/ 5269 at 12:27am, 9/26/2016, still 7 hours left. Usually China is day time next 7 hours, the rank will go down more.

  The experience was so different from her practice on Leetcode algorithm. She learned some new skills through long hours struggling. Most of things are about how to scale large data, timeout issue, out-of-memory. She found out the joy of programming.

  Some facts to set high standards, try to get into top 12% of contest, despite lack of preparation:

  It is a 48 hours contest. Saturday and Sunday two days.

 1. She only did one mile driving on last Sunday to spend 30 minutes to do grocery shopping, and two days to stay at home, worked on the algorithms.

  2. On Saturday, spent 8+ hours to work on an algorithm using interval (Leetcode 56: Intervals), worked on timeout, design issues, space issues - out-of-memory. Score 20 out of 20 after 8 hours work.

  3. On Sunday, spent 8+ hours to score 20 out of 40 - DP problem.
Still timeout, DP solution is not fast enough.
Spent  first 2 hours to work on dynamic programming test cases, figured out the recurrence formula.

Actionable items:

1. Spend some time to read those blogs about contests, figure out what to learn from. (plan to read 2 - 3 hours)

How other people review their contest?  (Ranking: 14/5000, score 345/ 400)

2. read blog 2+ hours, find ideas to work on

HackerRank profile:

3. another one:

4. Read some algorithms: (instead of Googling, use the website for reference - catch up - reading - plan to spend first 3 hours on this)

Another favorite of mine is — #2 HackerEarth (includes tutorials and separated into categories/sorted easiest to hardest)Algorithms Tutorials & Practice Problems
  • A note about this: I really enjoyed HackEarth’s previous practice section (it was a lot better formatted). If anyone can get this to HackerEarth executives, that would be a great piece of advice for them.

  Will document more later.
5. 9/28/2015
Some analysis - Julia only can score 15% (70/ 400) compared to best talent people in the world, if she works damn hard. Time wise, she could not solve difficult level algorithm yet, no data. 15% wise, She only score 70/400 in code sprint, but best one scores 400 in less than 10 hours.

But through the contest, she knows that she can close the gap and measure the progress in every month, every contest. Set up 5 stages - 15%, 25%, 30%, 40%, 50%, and relax and enjoy problem solving day by day.

HackerRank - world code sprint #7 - Gridland Metro

Sept. 26, 2016

Problem statement

 Julia spent over 8+ hours to work on this algorithm. She learned so many things, and most of important, she liked to train herself - strong determination, after 8+ hours, near 10pm, she was so surprised that she made full score 25 out of 25, because she started to adopt new way of thinking. She looked up her blog, and then find the idea:

  Avoid overcomplicate code

  from the blog

  So, she starts to practice advice she learned through reading, and then she enjoyed the great success on this problem solving.

  Will come back later to write more. More than 8 hours work, a lot of things to review.

   Come back on Sept. 27, 2016
1. submission 1: pass test case 1, score 0

 4 hours work, score 0; but the algorithm is working.

2. pass 3 of 30 test cases, score 1.67/ 25, 2nd C# practice.

3. score 1.67/ 25, 3rd C# practice.

4. score 4.17, pass 6 of 30 test cases, small progress, 4th practice.

5. try to pass any test case from test 7 - 30, failed once. 5th practice.

6. failed second try to pass test cases from 7 - 30, still score 4.17. 6th practice.

7. break through test case 7 -30, still failed, still score 4.17, 7th practice.

8. last try to break through test cases from 7 - 30, failed. still score 4.17

One thing for sure is that Julia has high standard now, she understands that it is important to continue to give up code, even write a new one,  if  code smells slightly.

Even if the code passes all test cases, but she likes to present code with good style.

Through the last 3 tries, she found several issues:
1. The bug she tried to fix is in different abstraction level, but stay in the same function. see line 218 - 222 of source code.

Code review under pressure was so exciting; Julia remembered the saying after 6+ hours continuous work - "avoid complicated code"; the function (line from 197 - 257 of source code ) is too complicated, doing too many things.

9. Score 25 of 25, more than 8 hours work - using LINQ, Lambda function, source code.

Highlights of change: break through test case 7 - 30

line 216: foreach (int row in sortedRows)  (section 8), source code.

The loop has the fatal weakness dealing with large, unknown data set, it leads to a unresolvable bug; In other words, collection

"sortedRows" can be filtered out more. Need to work on distinct row number.

line 212: foreach (int rowNo in distinctRows)  (section 9), source code.

Review after 6 month 

March 4, 2017

Julia reviewed the algorithm, and she was so surprised that she had to spend near 2 hours to relearn the algorithm, the code written in the contest had so many issues. She was happy to understand better how to write readable code after 3 months experience on

She wrote the C# solution and also asked the question. The blog is here and code review is here.

HackerRank - World CodeSprint #7 - Summing Pieces

Sept. 26, 2016

Problem statement

Julia is a warrior in the contest - fearless, she feels at home

Spent over 8+ hours to work on the algorithm, really enjoyed the algorithm. It is different experience, with strong determination to make some points, took more than 2+ hours to figure out the dynamic programming formula - should call recurrence formula. Started from scoring 4.00 points, moved up to 19.00 out of 40.00.

  What a learning experience, totally different from projects at work/ university. Will document the detail experience, what Julia should learn after she reviews/ analyzes the practice.

Will come back later.

Progression to 19/ 40

Step 1:
submission 1, pass first 3 test cases - score 4.14/ 40

Step 2:
score 11 out of 40 - step 2 / 4 (4, 11, 14, 19 out of 40)
use line 78, line 98, extra string array to help debugging the code, make it short to fix the issues in the code. But, this extra code has
to be removed later to gain 2 points.

Step 3:step 3 / 4 ( 4, 11, 14, 19 out of 40)

Step 4:
score 13.9

step 4:  score 19 out of 40

Six months later - follow up review

March 3, 2017

Review the algorithm, write a complete solution, and then post a question on

And also do some research how to win a silver medal, Julia was very close to a silver medal on this world codesprint #7,

HackerRank - World code sprint #7 - Similar Strings

Sept. 26, 2016

 Work on scalability issue related to string algorithm:

Will find 30 minutes to one hour, write some code and then start to learn through the practice.

Will come back later.


Julia spent more 8 hours to score 10 out of 40 on a dynamic programming algorithm Summing Pieces (medium level), actually she should spend 1 - 2 hours to work on this string algorithm.

Saturday, September 24, 2016

Vancouver woman tech - 2016 event in downtown Vancouver, Microsoft office

Sept. 24, 2016

  On Sept. 22, 2016, Julia enjoyed the trip to Microsoft new office in the city of Vancouver downtown, she enjoyed everything; so, she likes to write down the journey, reminds her that how hard people are working to make her life easy, happy, rich-learning experience day-by-day. When she has a little moment, she can come back here to get the spirit back, work hard again, to learn from 2016 WTA ranking No.1 Angelique, 3 Grand slams finals, 2 champions.

  Here are some twitter links for the detail of talk:




 And here are some personal experience of food, great view of downtown, and Microsoft office - art and inspiration things:

  It is close to Canadian Thanksgiving holiday, Oct. 10, 2016. But kind of nervous, try to rush in more projects to get more rewarding to finish 2016 strong.

Web usability research

Sept. 24, 2016

  Spent 2+ hours to do some research on web usability. At the end of study, Julia found the joy to watch TED talk from Margaret Gould Stewart, she knew that her study leaded to great experience of learning, expand her knowledge as a software programmer.

  First, let us have some highlights of study, then, have the detail of study.


Two TED talks:
1. Three lessons for designing for the whole world

2. How giant websites design for you and a billion others too?

  More details of study

kind of messy, will be organized better very soon.

1. From code smells study, move to next topic: web usability & user experience. (2+ hours study)

Borrow some ideas from website usability & user experience - Julia, you need to read 60 pages - page by page first.

Study Website Usability & User Experience (UX) Definition
(60 pages - plan to read 1- 2 hours, understand the concepts first)

How Code smells research leads to the website Usability research? User experience research?

It is an interesting journey, study clean code book -> code smells -> web usability ->  user experience (UX)

2.  Coding training -> More study on user experience, code readability, build good ritual before coding.

More reading

More Google search:
Margaret Gould Stewart facebook

Julia's favorite notes:

What’s really hard at designing at scale, is that it requires a bizarre combination of two things, audacity and humility.

Tuesday, September 20, 2016

A small research - web technology new school to catch up

Sept. 20, 2016

  Julia is preparing the list of things to learn through about new school web technologies. Her favorite project is to write a single web page application using Angular JS, bootstrap, MVC, entity framwork; and she likes to see people use her single page application one day, since small population uses her apps daily very often, for them, like Gmail app, a most popular single page application.

  So, she did some study about the teaching statement from the computer professor (From teaching statement: ):

I emphasize to students that the specifics of which programming languages, libraries, frameworks, and deployment services are in vogue at the moment change at a rapid pace, and that these new technologies are easy to pick up on-the-job once they have developed strong foundations. In my dynamic programming languages course, I take students on a deep dive of the Python interpreter source code to show them how a modern dynamic language is implemented from the ground up in C. Again, my goal is not to train students to become specialized Python developers, but rather to illustrate general principles that hold for any dynamic language such as JavaScript, Ruby, Scheme, and future languages that have not even been invented yet. I have noticed that students take a course more seriously when the instructor is firmly committed to rigor and high standards.

From teaching statement: 

Here is the list of web tool she likes to catch up:

The latest web tools and technologies, including:
  • JavaScript
  • EcmaScript 6/7 (via Babel)
  • HTML 5
  • CSS 3
  • JSON
  • React
  • Flux/Redux
  • D3
  • Webpack
  • REST
  • Node.js
Blog to read:

From my background, I draw three core pedagogical beliefs: to foster undergraduate research through apprenticeship; encourage experiential learning through studio-based, project-centric courses; and emphasize writing as a core academic skill.

Code smells - Book chapter reading

Sept. 20, 2016

Read clean code book - Chapter 17 - Smells and Heuristics

Julia's notes:

C1: Inappropriate Information
C2: Obsolete Comment
C3: Rudundant Comment
C4: Poorly Written Comment
C5: Commented-Out Code

E1: Build Requires More Than One Step
E2: Tests Require More Than One Step

F1: Too Many Arguments
F2: Output Arguments
F3: Flag Arguments
F4: Dead Function

General - (hightlights to help memorize - red color, Julia produced the code with smells...)
G1: Multiple Languages in One Source File
G2: Obvious Behavior Is Unimplemented
G3: Incorrect Behavior at the Boundaries
G4: Overridden Safeties
G5: Duplication
G6: Code at Wrong Level of Abstraction
G7: Base Classes Depending on Their Derivatives
G8: Too Much Information
G9: Dead Code
G10: Vertical Separation
G11: Inconsistency  - the principle of least surprise
G12: Clutter
G13: Artificial Coupling - lazy and careless of placement of a variable, constant or function
G14: Feature Envy -
G15: Selector Arguments

Great blog about clean code: CMU - top 4 computer science - a professor
"During the course of grad school, my relationship with my code has become increasingly important.  Clean, modular, and well-documented code (with tests!) is not only less likely to have bugs but will be useful for longer.  Clean code provides a solid foundation for you and potentially other researchers.  Modular code makes it easier to reuse parts of your code. Also, knowing exactly what your code does just feels good."

Editorial notes:
1. Clean, modular, and well-documented code (with tests!)
Julia, let us hold high standards as a software programmer -
Review common code smells before you write code for a project. 

2. Work on blog writing, and see if you can write good blogs as

3. work on the blog:

study writing - write down things to learn from the above article

4. Borrow some ideas from website usability & user experience - Julia, you need to read 60 pages - page by page first.

Study Website Usability & User Experience (UX) Definition
(60 pages - plan to read 1- 2 hours, understand the concepts first)

5. How Code smells research leads to the website Usability research? User experience research?

Sunday, September 18, 2016

HackerRank Stryker Code Sprint Grind summary

Sept. 18, 2016

Spent over 14 hours to work on the algorithm problem solving, hours to spend time to read problem statements. Score 233/ 560, rank 174/ 1936 participant

1. First algorithm:

2. Second algorithm:

3. Third algorithm: Two submissions.

4. Fourth algorithm:

5. Fifth algorithm:

6. Sixth algorithm: 

7. Seventh algorithm:

Plan to work on this algorithm later, study more problems related. Read algorithm books. 

Editorial Notes:

This is a fantastic journey to spend over 12 hours to battle on the algorithms. Julia built a very good physical strength and also good concentration on reading/ analysis/ coding. She enjoyed the live competition while she could analyze how many are successful on the algorithm, so she chose easy battle first. And also, Julia just learned to entertain herself while playing nice music along. 

Julia tried to solve seventh algorithm in order to break in top 100 ranking, but she was too late; 1:00am, she should have started early; She missed the first 3 hours because of time difference between EST and PST.

But, in other hand, Julia studied top performers - best one only uses 3 hours in total for all the algorithms. 

Julia will work on more training on herself. Just enjoy the contest.

HackerRank Stryker Code Sprint Grind (VI) - Julia and the Search Tree

Sept. 18, 2016

Problem statement:

Julia's solution using C#:

Could not believe her eye, Julia scored full score 100 out of 100 on a difficult algorithm.

Here is the timeline:

         * Julia and the search tree
         * problem statement:
         * 10:25pm - 10:47pm
         * read problem statement
         * Too many nodes in the tree
         * 1. Need to use iterative solution/ not recursive/ avoid stack overflow
         * 2. First construct the tree
         * 3. Then, maybe, add the calculation of sum
         * Submit on 11:23pm
         * Score 80 out of 80
         * Cannot believe that it is difficult level!

         * 10:53pm - start to write code
         * 11:14pm - finish to construct the binary search tree
         *   Need to think about timout?
         *   stack overflow?
         *   what else
         *   Need to add more tasks

Total time is less than 1 hour.

1. 22 minutes to read the problem statement
2. 26 minutes to write code, 10:52pm - 11:23pm
No bug, just score 80 out of 80. Unbelievable success.

HackerRank Stryker Code Sprint Grind (V) - The Hidden Message - 70%

Sept. 18, 2016

Problem statement

Julia's C# solution is here.

Here is the timeline Julia worked on the problem solving:

Section 1:
 /* 7:08pm - start to read the problem statement
     * 7:47pm start to write down her approach
     * start position is increasing
     * How to find word match?
     * Time complexity -
     * Data structure
     * Space complexity:
     * 7:55pm start to code
     * 10:04pm start to conduct testing

 Section 2: 
Copy the code from previous practice - substring search, using Boyer algorithm to speed up, avoid timeout issues. 
         * 8:24pm
         * copy code from blog:
         * 8:36 prepare to exit the function
        private static bool findUsingBoyerAlgo(string substring, string s, ref int start)

Section 3:
         * 9:02pm - start to code
         * 9:43pm - still work on the calculation of cost
         * - try to think about how many chars to be removed - second step
         * 9:57pm use brute force solution first
        public static string calculateCost(IList<Match> data,
            string message

Section 4:
     * 10:19pm
     * Summary of submission:
     * 40.80/60
     * Wrong answer for test case: 11, 15
     * Try to fix the bug

1. 40 minutes to read the problem statement
2. 2 hours coding - including eating a dinner - 20 minutes

55 minutes to work on calculation of cost, looked into interval algorithm, and then, figured out using brute force solution instead.

2. 10:04pm testing

Score 40.80/ 60 

Decided to give up bug fix, and then, moved on next question.

Study C# submission - 60 out of 60
1. Use Trie

2. C#: use dynamic programming.

Related to Leetcode 72: "Edit Distance"

3. Study the blog: Levenshtein Distance wiki

4. Study Java 8 solution - use Rabin Karp algorithm search class, DP

5. C++ code - Learn from the best, competitive programmer

6. C++ - KMP algorithm, DP

7. The programmer - 5 Gold - rank 32/1700
a Googler, a blog.

Talk about Google code review - in Chinese, link is here.

HackerRank Stryker Code Sprint Grind (IV) - Kth Zero - Second Try

Sept. 18, 2016

Continued to work on the algorithm, tried to solve the time out issues.

Here is the C# code:

Timeline of Julia bug fixing, aiming more points successfully:

         5:48pm - start to work on time out issue
         * 6:52pm - bug fix:
         * stack over flow
         * Are arrays or lists passed by default by refrence in C#?
         * Need to pass ref

The idea to solve timeout is to using O(n) time to copy the array instead of using O(nlogn) to sort the array.


1. 25 minutes to do analysis
    5:48pm - 6:07pm
2. 45 minutes to modify code 
   Worked on coding 6:07pm -  6:52pm
2.  and then, created a new bug, and then fix
Are arrays or lists passed by default by reference in C#?

Score 52/60, two test cases time out due to 3s
Julia's comment: Haha..., Julia, you could not figure out why? Read the study code #1, then figure out why.  (worked on it again on Sept. 19, 2016)

Study code:  (worked on it again on Sept. 19, 2016)
1. C#

Julia learned the lesson after she studied the above code:
In her solution, a hashset is used to get access O(1) for those zero numbers in the array. However, the hash function can not guarantee to perform as good as O(1).

Because the size of array is 10^5, it is the same thing to access O(1) if using binary search, which is log(N) = log(10^5) = 5 = O(1).
(Sept. 20, 2016 correction: log(N)=log(10^5) = 5 * log10 =5 *3.xx = O(1), since log 8 = 3. )

The fix of the bug is to remove the Hashset in the solution, call Array.BinarySearch to find the value.


Google search using keyword: 
C# sortedList analog in C++

Found the articles to read:

The SortedList<TKey,TValue> is the other sorted associative container class in the generic containers. Once again SortedList<TKey,TValue>, like SortedDictionary<TKey,TValue>, uses a key to sort key-value pairs. Unlike SortedDictionary, however, items in a SortedList are stored as sorted array of items. This means that insertions and deletions are linear - O(n) - because deleting or adding an item may involve shifting all items up or down in the list. Lookup time, however is O(log n) because the SortedList can use a binary search to find any item in the list by its key. So why would you ever want to do this? Well, the answer is that if you are going to load the SortedList up-front, the insertions will be slower, but because array indexing is faster than following object links, lookups are marginally faster than a SortedDictionary. Once again I'd use this in situations where you want fast lookups and want to maintain the collection in order by the key, and where insertions and deletions are rare.

Continuous work:
1. remove hashset from solution, C# solution, still time out on last 2 test cases.

2. A lot of C++ solutions - use bit manipulation, binary tree, segment tree, more complicated than I thought.

1. Segment tree - read the blog 10+ minutes

HackerRank Stryker Code Sprint Grind (III) - Kth Zero - First Try

Sept. 18, 2016

Problem statement:

Julia observed that more than 80% successful rate on this algorithm, so she chose to work this one (fourth one) first instead of "The Hidden Message" (3rd question).

Here are the time line Julia worked on the problem solving:

         * 3:46pm - 4:36pm
         * Read the question, and figure out the design:
         * Like database table using index, need to prepare index.
         * Only update query -
         *  1: case 1: replace the position which has value 0;
         *  2. additional element with value zero in the array
         *  Just put Hash table to the array, and then, sort the array O(nlogn).
         *  Maintain a hash table and array for value 0 in the array
         *  Otherwise, time complexity should be ok.
         *  To make sort minimum - only sort when next query of kth zero comes in,
         *  also set isDirty to track if update is need or not.
         * 4:36pm start to write code
          *5:30pm conduct testing.
          *5:48pm, timeout, and score 26/40 points

2.5 hours to work on first try.
1. 50 minutes reading time
2. 56 minutes to write first try
3. 20 minutes to conduct testing

Score 26/40 points, need to work on timeout issue

HackerRank Stryker Code Sprint Grind (II) - Point Filtering

Sept. 18, 2016

Problem statement:

Julia's C# implementation:

It was tough experience. Julia could not believe that how much time she spent time.

Here are the statistics, she tracked time spent while she wrote code; first time, she felt that it was important thing to do. More focus on the contest, come back to figure out what the issues are.

Here is the time line Julia worked on the algorithm: 
         * 11:20 start to read the question
         *       read 10+ minutes
         * Put some design notes together
         * bucket (size of b)
         * Add/ Delete/ Replenish
         * Req: maintain the size of b all the time
         * Main List
         * Sort
         * remove/ first b
         * remove top1
         * not empty
         * Time complexity: Sort using nlog(n)
         * Space complexity: Use Dictionary to store the points
         * Use integer to express 1.000 - 1000 instead of 1
         * 2:35pm start to test the program
         * 2:59 wrong answer after 1 key is removed from bucket
         *      continue to fix the bug related to replenish the bucket
         * 3:07 passed the sample test case
         * Summary:
         * Reading and design: 30 minutes
         * Coding: 1:27pm - 3:07pm
         * Testing: 30 minutes (2:35pm - 3:07pm)

1. 2 hours to read the problem, and thought about solution; while making a lunch, have a lunch
2. 90 minutes coding
3. 30 minutes testing

Score 40 (40 in total)

Actionable Items:

Big issue - Need to work on speed, time should be cut down from 3 hours to 30 minutes.

1. Study the C# submission:
No. 1:

No. 2:

No. 3:

No. 4:

No. 5:

No. 6:

No. 7:

C++ implementation:
No. 8:   less than 15 minutes:

No. 9:   less than 15 minutes:

No. 10:

No. 11:

Researcher, professor, Intel research:

Julia, read 30 submission using C++, full score, less than 60 minutes.

HackerRank Stryker Code Sprint Grind (I) - Minimum Index Difference

Sept. 18, 2018

Worked on first algorithm of HackerRand Stryker Code sprint - Minimum Index Difference

Julia's C# code, score 20 of 20.

HackerRank Stryker Codesprint Grind (VII): Maximizing The Longest Path - Stryker Codesprint

Sept. 18, 2016

Started from 11:30pm, worked on this difficult level algorithm:

Maximizing the longest path

Read problem statement 20 minutes, and then, read articles:

simple path in the graph

Will come back later on to work on this algorithm.

After 12 hours continuously coding, only 2 breaks for meals, and then, Julia gave up her try; Tried to break into top 50 - using DFS, NP problem solving efforts, until 1am.


Her first motivated grind - 11:00am - 1am over 14 hour long grind.


Stryker Codesprint:  Score 233 -  150/ 1766 participants (at 1am, 9/18/2016)

                                                     178/ 1766  

 Study code:

1. C++ 14


Friday, September 16, 2016

IBM Ponder this - Sept 2016

Sept. 16, 2016

  I knew IBM very well - since I lived in the city of Boca Raton, Florida over 14 years. And also Boca Raton is the city used to be headquarter of IBM in early 1990. And I used to work in the city of Delary for Siva corporation from June 2016 to August 2017, just one mile away from IBM office in Boca Raton.

 Always, I remind myself, from 1996 to 2010, I had a long journey over there. But, it is better to celebrate with an algorithm.

 So, I like to get into the algorithm practice sometime in short future. Use this algorithm to celebrate my 20 years experience in North of America, 14 years in USA whereas 6 years in Canada. In 1996, I moved to the city of Boca Raton; Just cannot believe it, like yesterday.

IBM Ponder this - Sept. 2016

Read this blog about solution of IBM Ponder this - Sept. 2016

blog reading:

Blog reading - Writing is best way to share the journey to excellence

Sept. 16, 2016

Computer professor of University of san Diego - very good advices - with details - plan to spend 3- 5 hours to go over the blogs

Best lecture in the world about rest API - quick lesson - Julia, learn it in 30 minutes

Statistics of the professor's great writing:

"In addition, I have written several articles on my website that are popular with students. For example,
my article on advice for applying to Ph.D. programs [2] has over 45,000 page views, advice on applying
to graduate fellowships [3] has over 95,000 views, and professional email writing tips [4] has over 42,000
views. I receive dozens of emails each year from students around the world asking for advice; I try to
answer as many as I can and then update my website articles to share that knowledge."

50 minutes video: The Ph.D. Grind

Blog reading: Getting Job at Google For PhD students

Sept 16, 2016

Just bring back all my memories about my computer science Ph.D. study - Let us get some reading today:

Great advice from Harvard professor/ Google manager/  Matt Welsh

Julia's notes:
Adherence to good design
Avoid overcomplicated code
Conforming to style guidelines

Concern about: robustness

Research lab does not provide training how to write clean code

Attention to details matters

Wednesday, September 14, 2016

A small research - WTA/ ATP players - good at motivating and winning

Sept. 14, 2016

  Small research topic: how WTA, ATP players motivate Julia to work hard in 2016. Julia enjoyed tennis from 2012 - 2014, she spent whole day on the tennis court if possible, she enjoyed the time and also tried to lose as much weight as possible, built as much muscle as possible. But, then in 2015, she started to catch up on Leetcode algorithm problem solving. She has to watch out the efficiency of workout, deal with tennis elbow, muscle pain etc. issues, meanwhile, she studied a lot how professional players do their business.

 Things she learns:
1. How players focus on the training, matches?
2. How players are working hard on their physical fitness/ strength training?
3. How good/ relax players are touring the whole world? work with coaches and peers?

 Julia follows a lot of WTA, ATP players. Just 3 months ago, she started to follow Karonlina Pliskova.

1. Top 10 of 10 ranking:
Karolina Pliskova

I learned to stay and work hard every day to get the chance to be the best

US Open 2016 final

How to apply those to daily job as a software programmer?
How to set high standards?

Related to Amazon principle leadership - Insist on the highest standards

Leaders have relentlessly high standards

2. What does Stan Warinka's Tattoo say?   (Top 10 out of 10)

On the inside of his left arm are the words of poet Samuel Beckett: Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better. He did his tattoo in 2013.

2016 US open ATP champion

Actually, the failure is most important part as a professional player. There is only one champion. So, there is a ranking system, players have to work hard to maintain the ranking in top 100.

Try, fail, try again, fail again, fail better. The idea of fail better is to help yourself also others. Build up a very good ritual to do training.

Related to Amazon leadership principle -  customer obsession

3. Kristina Mladenovic

2016 Australia Open 3rd Round, 2016 French Open WTA double champion

I don't feel fear when I am on court. That's where I feel at home

Culture of Arista Network - No fear

Train insane or remain the same - focus on training!

Leetcode 61: rotate list

Sept. 14, 2016

C++ implementation:

Start a drill to memorize the implementation:

1. How many variables are used in optimal solution?
2. How many lines of code?

Leetcode solution blog:

Reading blogs:

3. Fernando Pereira - Distinguished researcher in Google

I like to state it as "the language of successful communication within Google is good code, not slides, proofs, or research

Leetcode 98: validate binary search tree

Sept. 14, 2016

C++ implementation:

Start a drill to memorize the implementation:

1. How many variables are used in optimal solution?
2. How many lines of code?
3. What are not in the optimal solution?
4. ...

Leetcode solution blog:

Will write C# implementation very soon.

First contest medal from HackerRank - world code sprint #6

Sept. 14, 2016

Fun facts about HackerRank world code sprint #6:
1. Julia won her first Bronze medal! Excellent! a big surprise!
Get into top 25% - Bronze medal (Gold 4%, Silver 8%, Bronze 13%)

2. Julia worked on a simple question: Flip matrix more than 1 hour
problem statement:

C# practice:

She was so interested in the flip part, later, she figured out that the algorithm should not be so complicated. It is just a medium level one.

3. Julia learned DFS/BFS algorithm through HackerRank, she found the joy to read code and try to write one for every different idea.

4. Being a programmer, it is hard to control your luck. But HackerRank contest looks like more controllable. More practice leads to more medal. Julia likes a silver one next time. <- Nothing is impossible! top 12%. Julia tried to stay overnight Saturday night, get in top 600/ 12%. 

Fun facts: 
1. More than 5 computer professors / score range: around 200 score, silver medal, 230 - 270 ranking. 
2. Julia, work hard, try some difficult level algorithm day by day. 

Blog review:

Sunday, September 11, 2016

Code smells - small research

Sept. 11, 2016

Small research about Common code smells

Warm up the topic:
1. Reduce stress to write and also maintain the code
2. Build a good habit to write/ refactor code/ design concern/ thinking logically,
3. Amazon leadership principle: internal customer support -> external support, high standard, genesis of AWS - from infrastructure support to AWS

Insist on the Highest Standards
Leaders have relentlessly high standards

Train to be a leader.
End of warm up

On Sept. 12 evening, spent 2 hours reading code smells -
Read the boook "refactor "

Code smells:
Refactoring: Improving the design of existing code

Chapter 3: Bad smells in code:
Duplicate code   ()
Long method      ()
Large Class
Long Parameter Lsit
Divergent change
Shortgun surgery
Feature Envy
Data Clumps
Primitive Obsession
Switch Statements
Parallel Inheritance Hierarchies
Lazy Class
Speculative Generality
Temporary Field
Message Chains
Middle Man
Inappropriate Intimacy
Alternative Classes with Different Interfaces
Incomplete Library Class
Data Class
Refused Bequest

End of 2 hours of reading - have the above notes

Read the article:


Julia's Notes

Application-level smells:
1. Duplicate code
2. Contrived complexity

Class-level smells:
1. Large class
2. Feature envy
3. Refused bequest  (Liskov substitution principle)
4. Lazy clss/ freeloader
5. Excessive use of literals
6. Cyclomatic complexity
7. Downcasting
8. Orphan variable or constant class

Method-level smells
1. Too many parameters
2. Long method
3. Excessively long identifiers
4. Excessively short identifiers
5. Excessive return of data


a positive correlation between cyclomatic complexity and defects: functions and methods that have the highest complexity

tend to also contain the most defects

3.Static program analysis

Blog reading:
Leetcode 247: Segment Tree Query (II)
Leetcode 247 Segment Tree Query (II)

Will come back to work on the algorithm.

Julia's most favorite concept - Cyclomatic complexity - No more long function!

HackerRank contest - stryker codesprint preparation talk

Sept. 11, 2016
It is always a good idea to learn how to prepare very well for a programming contest. Five days away. Let us count down.

Preparation of the coming contest:
Register stryker codesprint  - Sept. 17, 2016

Get prepared, and things to look into:

1. How to prepare for the codesprint?

1. Read the competitive programming book - time analysis, data structure etc.

2. Learn to solve problems using traditional solutions

3. Read some Leetcode solutions - 2+ hours

4. Read the article - why the company sponseres codesprint?

Julia only has 4 contests so far/ less than 6 months contest experience vs people over decades of contest experience; be realistic, be pragmatic

Read the article:

Borrow ideas from professional tennis players and teaching pros on contest preparation:

Professional WTA player habits:


Practice to win
Learn to concentrate

Visulization/ margin of error -

2. The 7 Habits of Successful Teaching Pros

Blog reading:
1. How to spend the time?

Julia's note: apply separation of concern, abstraction level -> go to various abstraction level -> various functions, main

concern/ trivial jobs;
main target is to cut time to short, leave time for second question, or things to ask.

5 minutes costs a job - in other words, give different priority for different tasks -
45 minutes interview time / 25 minutes is a threshold - do not push over 25 minutes, leave 20 minutes for something more

meaningful - prepare questions to ask/ figure out if you are best fit/ what is biggest hurdle to overcome

2. 20 minutes reading:

3. Leetcode 307: Range sum Query
Spent time to read segment tree - 2.3.3, page 22, 23, 24, competitive programming book.

 So, Julia likes to have some practice on segment tree.

Will come back very soon.

HackerRank - String function calculation (II)

Sept. 11, 2016

Plan to find time, at least 30 minutes, warm up the algorithm next week first, and then, continue to work on this advanced problem - suffix array, LCP, two pointer techniques.

After 5 month (April, 2016), come back to work on the algorithm, using suffix array, LCP, two pointer technique:

Previous work on suffix array


More in detail:
Practice 1: brute force, score 8.89 out of 80 - April 10, 2016

Practice 2:

Timeout issue - find ways to cut down the time - string algorithm - Boyer Moore

Practice 3: suffix array, still time out

Plan to work on LCP array later - took 5 months break

LCP first practice using Trie  - Sept 12, 2016

Read competitive book, learn the TLE - time limit exception - how to evaluate,

Preparation:  (Sept. 15, 2016 1+ hour reading)

Study Algorithm Edition 4 - Robert Sedgewick/ Kevin Wayne

Page 875-885 Suffix Array

Friday, September 9, 2016

Blogger -> pdf book

Sept. 9, 2016

 Small research for a blogger, how to convert the blog to pdf file? 

 First pdf book Julia wrote - over 780 pages - 12 months / 9/8/2015 - 9/8/2016. 

1. Prepare for a trip
Julia plans to take vacation from Sept. 29 - Oct. 16; but in China, google/ Gmail/ blogger is blocked, no access. 

2. To share the blogger to friends in China is impossible, convert it to pdf first. 

1. How to convert blogger to pdf?

2. pdf book - coding blog from Sept. 8 - 2015 - Sept. 8 2016

Wednesday, September 7, 2016

Performance review - HackerRank world code sprint #4, #5, #6

Sept. 7, 2016

Review performance of coding contest on HackerRank: 

Log of performance - HackerRank world code sprint #4, #5, #6, from score 40 to 100; in other words, from nothing to the first bronze medal. Excellent experience.   

Spend some time to review the performance of 3 contests Julia did from June to August 2016. 

No. 1: 
world code sprint #4 - score 40/?, bet on algorithm AorB (medium level)HackerRank: AorB - intense workout - 3 hours+
- score 0 of 50, 5+ hours. 

No. 2
world code sprint #5
 - forgot to attend, worked on the algorithm next day. Finished first 2 questions, 40/430, spent time to read all questions - read 1 expert question, 2 advanced questions, 1 difficult, 2 medium. Just enjoy all the questions by reading the problem statement again and again, 3+ hours. See how many things she missed in every reading, every new thing she found through one more reading.  

She wrote one of her most popular blogs: 3+ hour struggle to score 13/ 40, so enjoyable. (145 views up to Sept. 16, 2016, including herself to edit the blog)

No. 3
world code sprint #6 - score 100/380, first 4 algorithms full score, worked on 5th algorithm - Bnetrousel (medium level) more than 3+ hours, score 0 of 50. Bronze medal, top 25%. Tried to get into 10%. She did not know that time 10% means silver medal when she worked on the algorithm. 

Analysis of performance: 
Julia must have learned a lot through the practice of those 3 world code sprints; she never expects that she can be one of people having some medals with HackerRank so soon - from June to August, 2016, 3 contest practice. 

1. Most valuable experience from world code sprint #4, June 26, 2016

She learns that in order to perform in less than 30 minutes, she must work on the small, simple, well-defined problem from the very beginning. 30 minutes beats hard-working 8 hours. First time, she experienced two approaches with over 10 times performance difference (0.5 hour vs 8 hours). She likes to make the smart choice every time ever since.

2. Most valuable experience from world code sprint #6, August, 2016
Time complexity analysis. It does not matter if queue/ stack/ recursive function is used in the design,  most important is to analyse time complexity first - from brute force to optimal, try to target the optimal time complexity. Mathematics is so important to the problem solving, it does not matter if the math is so easy, how hard  to figure out. Know the time complexity range, brute force vs optimal solution; aim high target! play to win!

Most favourite tip from
 Rather than performing perfectly, perform to see improvement (10 out of 10)
 Focus on the Journey, not the Destination (9 out of 10)
 Recognize when you are using negative self-talk and replace it with positive (8 out of 10)

Actionable items:
1. Set long time goal - attend more contests, try to score 200 points one day. 
2. Finish competitive programming book - 150 pages. 
3. Go over Leetcode questions one by one, by reading the solution.