Sunday, September 18, 2016

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:
         * http://juliachencoding.blogspot.ca/2016/04/hackerrank-string-function-calculation_10.html
         *
         * 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
     */

Summary:
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:

https://gist.github.com/jianminchen/d53550f39f4425734030c874463b5881

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.

Summary: 

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#
https://gist.github.com/jianminchen/9cdbdcefd84e3cb8e709eabf705ce4b0

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. 

https://gist.github.com/jianminchen/d53550f39f4425734030c874463b5881


2.
https://gist.github.com/jianminchen/63172e67001956e75abae02d079c668d

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

Found the articles to read:
http://landenlabs.com/code/containers/index.html

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.
https://gist.github.com/jianminchen/a865fd512e176ecf973338036db563c7

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 

http://www.geeksforgeeks.org/segment-tree-set-1-sum-of-given-range/

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

Sept. 18, 2016

Problem statement:
https://www.hackerrank.com/contests/stryker-codesprint/challenges/kth-zero

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).

https://gist.github.com/jianminchen/f0de5ad6cda7e75df5d6c18a36c41a99

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
         */

Summary: 
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:

https://www.hackerrank.com/contests/stryker-codesprint/challenges/point-filtering

Julia's C# implementation:

https://gist.github.com/jianminchen/41a5b656f3aeacde37588adef261d4a2

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)
         */

Summary:
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: 
https://gist.github.com/jianminchen/ada496ab333e962988ca088a07deeac3

No. 2:
https://gist.github.com/jianminchen/5dc56ab8d69496c0c12e35ab5ccbeb73

No. 3:
https://gist.github.com/jianminchen/980c5626de67f33f2a39dee33eb770a8

No. 4:
https://gist.github.com/jianminchen/715754585de580142d514905c3ab4fea

No. 5:
https://gist.github.com/jianminchen/877ff5d9f0026ed007e55ef7386fd5a9

No. 6:
https://gist.github.com/jianminchen/e0a94f4f3b9432a81b51b68951647a8a

No. 7:
https://gist.github.com/jianminchen/e9ddff599b7ec3cfe53dd7d5c20f66bd

C++ implementation:
No. 8:   less than 15 minutes:
https://gist.github.com/jianminchen/61bdc567cb42b172ffc35f67a6442ff7

No. 9:   less than 15 minutes:
https://gist.github.com/jianminchen/e88c8e354af2a810fef03f64e4d228c6

No. 10:
https://gist.github.com/jianminchen/652c78955e9999e3ab5759fb9358f69e

No. 11:
https://gist.github.com/jianminchen/59fa3914b92b71dce3f707c62fdf99ab

Researcher, professor, Intel research:
https://www.hackerrank.com/kmalinau



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

https://www.hackerrank.com/contests/stryker-codesprint/challenges/point-filtering/leaderboard

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

Sept. 18, 2018

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

https://www.hackerrank.com/contests/stryker-codesprint/challenges/minimum-index-difference

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

https://gist.github.com/jianminchen/a377bac6ff6a2b459db462b0e2506470

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

https://en.wikipedia.org/wiki/Path_(graph_theory)

https://en.wikipedia.org/wiki/Longest_path_problem

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.

Celebration:

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

Statistics: 

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

http://www.research.ibm.com/haifa/ponderthis/challenges/September2016.html

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

https://anothercasualcoder.blogspot.ca/2016/09/ponder-this-sept-2016-permutations-dfs.html

blog reading:

http://www.hercampus.com/school/duke/melinda-gates-being-woman-tech?linkId=28873720

http://blog.csdn.net/philipsweng

http://www.mimuw.edu.pl/~erykk/xe-contest.php




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

http://pgbovine.net/programming-interview-tips.htm

http://pgbovine.net/do-what-you-love.htm

http://pgbovine.net/motivation-momentum-marketability.htm

http://pgbovine.net/apps/faculty-2012/pguo-cover-letter_2012.pdf

http://pgbovine.net/productivity-tips.htm

http://pgbovine.net/unicorn-jobs.htm

Best lecture in the world about rest API - quick lesson - Julia, learn it in 30 minutes
http://pgbovine.net/rest-web-api-basics.htm

http://pgbovine.net/apps/faculty-2012/pguo-teaching-statement_2012.pdf

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
https://www.youtube.com/watch?v=zHp2rxR2LTc

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
               Scalability
               Testability
               Performance

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
https://www.amazon.com/p/feature/p34qgjcv93n37yd


Leaders have relentlessly high standards


2. What does Stan Warinka's Tattoo say?   (Top 10 out of 10)
https://twitter.com/jianminchen/status/752276919169626112

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
https://www.amazon.com/p/feature/p34qgjcv93n37yd

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:
https://github.com/derekhh/LeetCode/blob/master/61_v1.cpp

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:

http://juliachencoding.blogspot.ca/2016/09/a-drill-c-learning.html

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
prototypes".

https://plus.google.com/+FernandoPereira


Leetcode 98: validate binary search tree

Sept. 14, 2016

C++ implementation:
https://github.com/jianminchen/LeetCode-17/blob/master/98_v1.cpp

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:

http://juliachencoding.blogspot.ca/2016/09/a-drill-c-learning.html

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%)
https://www.hackerrank.com/scoring/rating

2. Julia worked on a simple question: Flip matrix more than 1 hour
problem statement:
https://www.hackerrank.com/contests/world-codesprint-6/challenges/flipping-the-matrix

C# practice:
https://gist.github.com/jianminchen/856f97a7f01f049efbde50078b7699ba

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:
1. http://juliachencoding.blogspot.ca/2016/04/talk-about-coding-performance-concerns.html

Sunday, September 11, 2016

Code smells - small research

Sept. 11, 2016

Small research about Common code smells

Warm up the topic:
Benefits:
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

https://www.amazon.jobs/principles

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 "
http://goo.gl/8r2AJO

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
Comments

End of 2 hours of reading - have the above notes

Read the article:

1.https://en.wikipedia.org/wiki/Code_smell

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

2. https://en.wikipedia.org/wiki/Cyclomatic_complexity

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
https://en.wikipedia.org/wiki/Static_program_analysis

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

http://www.tangjikai.com/algorithms/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
http://juliachencoding.blogspot.ca/2016/09/a-drill-c-learning.html


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

https://www.hackerrank.com/codesprint5/sponsor
https://www.hackerrank.com/work/customers/rocketfuel
https://www.quora.com/What-is-the-benefit-of-solving-problems-on-HackerRank

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:
https://en.wikipedia.org/wiki/Competitive_programming

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

Professional WTA player habits:

1. http://www.humankinetics.com/excerpts/excerpts/learn-the-practice-habits-of-tennis-professionals

Practice to win
Learn to concentrate

Visulization/ margin of error -

2. The 7 Habits of Successful Teaching Pros

http://www.tennisindustrymag.com/articles/2011/01/2_the_7_habits_of_successful_t.html

Blog reading:
1. How to spend the time?
https://www.quora.com/What-are-some-tips-for-programming-interviews-Amazon-Facebook-Microsoft-etc

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:
http://www.mohsinali.net/guide.html#prep

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:

https://www.hackerrank.com/challenges/string-function-calculation

Previous work on suffix array


1. http://juliachencoding.blogspot.ca/2016/04/april-11-2016-plan-to-work-on-lcp-array.html
2. http://juliachencoding.blogspot.ca/2016/04/april-11-2016-plan-to-work-on-lcp-array.html
3. http://juliachencoding.blogspot.ca/2016/09/first-code-practice-trie.html

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

http://juliachencoding.blogspot.ca/2016/04/hackerrank-string-function-calculation.html

Practice 2:

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

http://juliachencoding.blogspot.ca/2016/04/hackerrank-string-function-calculation_10.html

Practice 3: suffix array, still time out

http://juliachencoding.blogspot.ca/2016/04/hackerrank-string-calculate-function-iii.html

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

LCP first practice using Trie  - Sept 12, 2016

http://juliachencoding.blogspot.ca/2016/09/first-code-practice-trie.html

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. 

Motivations:
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? 
http://www.slideshare.net/fionabeal/convert-your-blog-to-a-pdf-and-a-word-file

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

https://github.com/jianminchen/juliaCodingBlog/blob/master/juliacodingBlogSept8_2016_Oneyear.pdf

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)
http://juliachencoding.blogspot.ca/2016/07/short-palindrome-hackerrank-world.html

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
http://juliachencoding.blogspot.ca/2016/06/hackerrank-aorb-interesting-struggle.html

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 http://juliachencoding.blogspot.ca/2016/09/8-tips-coaching-tips.html:
 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. 



10 Tips to help you perform to your highest potential in coding

Sept. 7, 2016

Borrow some tips from tennis coaching, try to apply coding practice, algorithm problem solving practice, programming contest.

Memorize 8 tips to help you to perform to your highest potential in Tennis (? code practice, etc.): 
1. Let go of what others think
2. Perform for yourself, not to impress or to "not disappoint" others
3. Accept that you will make mistakes, and let them go
4. Focus on what you can control
5. Recognize when you are using negative self-talk and replace it with positive
6. Rather than performing perfectly, perform to see improvement
7. Be objective about your performance, not subjective
8. Focus on the Journey, not the Destination
9. Celebrate your success
10. Stay at the moment
- Julia likes to calm down quickly when she gets nervous. When she has a negative self-talk, she will remind herself - "Everyone faces challenges on court and I'm no different." Replace with positive self-talk.

Longest Common Prefix - using Trie

Sept. 7, 2016

Work on C# practice:
http://www.geeksforgeeks.org/longest-common-prefix-set-5-using-trie/

One of longest common prefix series:
1. http://www.geeksforgeeks.org/longest-common-prefix-set-1-word-by-word-matching/
2. http://www.geeksforgeeks.org/longest-common-prefix-set-2-character-by-character-matching/
3. http://www.geeksforgeeks.org/longest-common-prefix-set-3-divide-and-conquer/
4. http://www.geeksforgeeks.org/longest-common-prefix-set-4-binary-search/
5. http://www.geeksforgeeks.org/longest-common-prefix-set-5-using-trie/

Will work on coding very soon.

C# practice:
https://gist.github.com/jianminchen/d65887908a16e1c12d708a2912c4c081

Add time complexity and auxiliary space detail:
Time Complexity : Inserting all the words in the trie takes O(MN) time and performing a walk on the trie takes O(M) time, where-
N = Number of strings
M = Length of the largest string string
Auxiliary Space: To store all the strings we need to allocate O(26MN) ~ O(MN) space for the Trie.
From the website:

Editorial Notes:
1. This is the first C# implementation of Trie Julia wrote.

2. How does she get here?
HackerRank code sprint #6 has an algorithm related to suffix array ->
continue to work on suffix array ->
Longest common prefix ->
string search speed up ->
found a 5 solution series on geeksforgeeks ->
work on 5th solution, Trie, LCP

3. Prior experience worked on suffix array:
http://juliachencoding.blogspot.ca/2016/04/april-11-2016-plan-to-work-on-lcp-array.html
http://juliachencoding.blogspot.ca/2016/04/april-11-2016-plan-to-work-on-lcp-array.html

Try to solve the advanced problem again after 5 month (April, 2016) using suffix array, LCP, two pointer technique:
https://www.hackerrank.com/challenges/string-function-calculation




Lecture study - Scalability Harvard Web Development

Sept. 7, 2016

Work on system design, spend 2 hours to study the lecture.

 https://www.youtube.com/watch?v=-W9F__D3oY4

Lecture notes:
http://cdn.cs75.net/2012/summer/lectures/9/lecture9.pdf


Write down some keywords from the lecture, and then, google search on them.

Open courseware:

http://cs75.tv/2012/summer/

Monday, September 5, 2016

Sports training - strong back muscle

Sept. 5, 2016

Learn from sports training -
Do some research how professional players conduct training.

Personal story to warm up the topic


Early in 1998, in Florida state of USA, Julia suffered first back pain injury because she did not exercise regularly, she could not turn one side if she lies on the bed without using her arm to help, over 1 week; In 2001, she suffered a few back pain incidents as well.

Since 2011, Julia started to play tennis regularly, invest time to do some research on fitness, nutrition. She did not have back pain anymore, because if she sits too long for a few days, she knows that back pain will come back; she takes breaks to play tennis for a few hours, a lot of running, a lot of tennis forehand swing and backhand swing, and other conditioning exercise. Hour spent on tennis, 500+ hours (Just guess, last 5 years)

So, it is important to change the life style, play more sports, be more healthy.

Now back to the topic.


Sports training / Coaching 



Julia always learns from professional tennis players, how they handle training, work with coaches, and handle difficult time as a professional player up-and-down in ranking etc.

She learns from sports, always prepare, get more training before she works on a new project in her career.

Through her tennis training, she learns from her most favorite tennis players - Angelique, Maria Sharapova, Ana, through training videos. She starts to examine her training, discipline herself, use a variety of tools, work on more warming up etc.




Sharapova training video








Ana trainging before tournament, 15 minutes warm up using medicine balls, and all other routines, using elastic strips to stretch arm muscles etc.



More training videos: (Ana Ivanovic)

Fast activity, lower center gravity, a lot of drills - work with ladders, tones, fitness trainer, stretch etc.

Do not over training, do not push too hard.

https://www.youtube.com/watch?v=0rXncq7dO4E

https://www.youtube.com/watch?v=JqBbuhZEKIg

Throw tennis balls, to sky, to forward, etc.

https://www.youtube.com/watch?v=tLyv-VXW9v4

Fitness, coordination, strength, balance, speed, - scott byrnes - strength and conditioning coach
3 coordination - head and eye coordination
Prevent injury - structure in your training

https://www.youtube.com/watch?v=Lm-IO7mRRC4

How a coach helped so many WTA top players to achieve success?

http://www.wtatennis.com/news/article/5287997

Competitive Edge Sports Performance Tennis Training Drills -

https://www.youtube.com/watch?v=7dd07b1bnaQ
https://www.youtube.com/watch?v=OvLicjixeoc

Fitness Drills for Tennis Players - Tennis Now

https://www.youtube.com/watch?v=kb4IkMbNElE

Spider's drill is such a great idea - learn how to get down low, work on quad and string muscles.

Coach's talk - more focus, move to net, top 5 players - coaching is not an easy job.


Sports talk: onsite coaching, long hour match, interview, double partner

Sept. 5, 2016

 Once a while, Julia likes to do some research on the tennis sport. She tries to educate herself, knowledge about her favorite tennis sports, and also get educated with interview talks, and smart challenges like choosing a double partner in the tennis sports. 
  
  Here are 5 things she chose to work on: 

  1. Angelique Kerber interview after US Open 2016 3rd round
  2. coaching - onsite coaching - WTA 2008 No. 1 player 
  3. underdog big surprise - US open 2016 4th round - Luca Pouille
  4. 5 minutes tour of central park by your favorite winner
  5. how to choose competitive partner - after WTA double player top 1 made a cold call

Let us have some sports talk in this blog: 
1. WTA No. 2 Angelique Kerber interview after US Open 2016 3rd round
1 year ago, none of second week of big tournament
last few months, going to No. 1.

Improvement in attitude: 
Try to enjoy the game, less nervous; bring out best performance

About No. 1 ranking, how do you think about itÉ
Focus on next game. A long way to go.

https://www.youtube.com/watch?v=q4S7alsq0-4

1. How to coach best top performer in real life? 2008 WTA No. 1, Ana Ivanovic. 
Don't know what to do?
Be clear on your head. Execute your game plan. ..., Let us get rhythm back. Come on. 
https://www.youtube.com/watch?v=qiR5M_7FJd8 


2. Luca Pouille US Open 2016 - INTERVIEW -

https://www.youtube.com/watch?v=I_TkcSxSyR0

How to beat 16 14 grand slam champion in US open fourth round? 
Be aggressive all the match.

What is the game plan? 
Just enjoy the match, as a player. It is a game, you have to enjoy it.

How do you draw a line between enjoying something and be fierce and be competitive?
You want to win.
I have a chance to win. Be aggressive. Otherwise, you will run, run, run to death.
Coach told him, you will make a lot of mistakes, but you will also make a lot of wins.

Take his chance to win match point in tie-break match.

3.Pouille Explores Central Park Ahead of US Open 2016
https://www.youtube.com/watch?v=NOAoHhWIeGk&index=6&list=PLpjoBM_v3S6EaPxZ2N4gZY4Zk_9Qo3gHH

4. Reading the blog:
http://www.tennis.com/pro-game/2016/09/martina-hingis-coco-vandeweghe-doubles-2016-us-open/60686/
https://www.quora.com/How-do-professional-tennis-players-choose-doubles-partners-to-play-with

Actionable Items:
1. Study more interviews of tennis sports. And see commentator leads interview, what words, when, why he/ she do that.

21 minutes - Angelique Kerber R4 Presser - Sep 4, 2016
https://www.youtube.com/watch?v=w_r1HzOMCnU

Question: New York vs Australia grand slam?
Keep things simple; loud everywhere.
Plan something, 2 hours extra

Question: Pressure level? After first grand slam win, before and after?
To find the middle ground. Recall the feeling of first round retiring, or get grand slam.

Question: about Ranking, approaching No. 1
Try not to put pressure on myself - talk about No. 1, kid`s dream. Step by step, we will see.

Question:
In the past, too much pressure on myself; I lost a lot of matches; Try to focus on other things.


2. How the top performer works with the coach outside the court and on the court, live matches?

3. Study the website:
The desktop version/ mobile version, the art, layout, and also organization of structures/ different sponsors, very good design.

http://www.anaivanovic.com/profile

Suffix Array and longest common prefix array (LCP array) - study

June 5, 2016

 It is the labor day long weekend, spent 3 hours (6:30am - 10:00am) to read suffix array from this favorite competitive programming book, and try to please herself, a new goal - score any point with suffix array work or LCP (even cannot remember the full name - called longest common prefix array), HackerRank practice or code sprint.

It is a lonely journey - reading the book, but it is perfect for physical recovery  - muscle and bones -
laying on the bed with the excellent one night sleep, just after 3+ hour tennis sports, and do not want to move, read a book.

Yesterday, Julia warmed up more than 1+ hour, one single match, one double match lasted more than one hour, until tie break. She lost double with 5 to 7 lost the match.  She suffered tennis elbow pain issues.

The competitive book about suffix array:

6.4 Suffix Tree and Suffix Array - page 114 - 119


Motivation talk
1. suffix array - who did the research to introduce the term - suffix array in 1993?

 https://en.wikipedia.org/wiki/LCP_array
 https://en.wikipedia.org/wiki/Udi_Manber

More reading:
Suffix array:
http://algs4.cs.princeton.edu/63suffix/

Play with some code first, get solid understanding suffix array - what are the benefits using suffix array? Shorten time complexity - 

suffix tree -> suffix array -> sorted array -> LCP - longest common prefix

Arguments:
1. Building efficient Suffix Tree under contest environment is a bit complex and risky
2. Suffix Array invented by Udi Manber and Gene Myers, has similar functionalities as Suffix Tree but simpler to implement, especially in programming contest setting
3. ...

Facts:
1. Suffix Array is an integer array that contains indices of sorted suffixes


1. Write C# version of this Java code:
http://algs4.cs.princeton.edu/63suffix/SuffixArray.java.html

2. Suffix array - longest repeated substring - using suffix array
http://algs4.cs.princeton.edu/63suffix/LongestRepeatedSubstring.java.html

3. Keyword in context (KWIC)
Given the suffix array, easy to search for a string or sentence via binary search. Memory is linear. Search is O(K log N) where K is the length of the string you are searching for. (Can be done in K + log N by using the lcp array.)

study the code:

More reading:
1. https://leetcode.com/articles/longest-common-prefix/

2. http://www.geeksforgeeks.org/longest-common-prefix-set-1-word-by-word-matching/
3. http://www.geeksforgeeks.org/longest-common-prefix-set-2-character-by-character-matching/
4. http://www.geeksforgeeks.org/longest-common-prefix-set-3-divide-and-conquer/
5. http://www.geeksforgeeks.org/longest-common-prefix-set-4-binary-search/

- Julia likes to calm down quickly when she gets nervous. When she has a negative self-talk, she will remind herself - "Everyone faces challenges on court and I'm no different." Replace with positive self-talk.

Sunday, September 4, 2016

Leetcode 72: Edit distance - code study

Sept. 4, 2016

First thing in the morning, this Sunday, labor long weekend, Julia read the book about "competitive programming. She read the book -
page 112,
6.3 String Processing with Dynamic Programming
6.3.1 string alignment - edit distance

Using Dynamic Programming, she was amazed that how good the solution is provided in the book. She read aloud the analysis and solution word by word, sentence by sentence, a few times. So enjoyable experience.

The book is detailed in the previous blog:
http://juliachencoding.blogspot.ca/2016/09/book-reading-competitive-programming.html

So, she looked up google and found the similar algorithm: Leetcode 72 - edit distance
Problem statement: (Hard)
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)
You have the following 3 operations permitted on a word:
a) Insert a character
b) Delete a character
c) Replace a character
Blog reading:
1. Machine learning - 
http://www.hpl.hp.com/news/2011/jul-sep/luluhe.html

Saturday, September 3, 2016

A small research - project management

Sept. 3, 2016

  Julia plans to train herself to improve her skills - project management skills. As a programmer, she learns that the contributions of a single programmer can do. As an old saying, a great programmer can beat a five or six ordinary programmers, maybe a team.

  To prepare herself, prepare early, prepare continuously, she likes to push herself read, memorize APIs, before she writes the code. She values the training, every lesson she learns from the training, all kinds of activities.

  Case study:
  One project she likes to work on is to build up a website for most of mobile users. She starts to read and write down notes about mobile phone, commercial, marketing terms about new release mobile phone.

  A list of preparation for the mobile website:
1. study latest mobile phone products, learn market terms: such as retina display, human eye - 300ppi
2. a few months to learn Angular JS, MVC, entity framework etc.
3. JavaScript training
4. CSS training
5. Write bug free, solid code

  Google - keyword search:

  Will come back to work on this later.

System design - a new skill to acquire

Sept. 3, 2016

  Work on the first system design blog, and learn the basics of system design:

http://juliachencoding.blogspot.ca/2016/08/system-design-design-url-shortening.html

  Continue to work on System Design day by day. (Plan to work on M. W. Fr. 8:00pm - half hour)

https://github.com/jianminchen/system_design

System Design:

design a Twitter website:
http://www.hiredintech.com/data/uploads/hiredintech_system_design_the_twitter_problem_beta.pdf