Wednesday, September 7, 2016

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




Friday, September 2, 2016

Book reading: competitive programming

Sept. 2, 2016

Plan to spend 30 minutes a time, up to 10 hours to read a short book - 152 pages first.

Competitive programming course:

Free download - version 1


Julia spent more than 1 hour to look into lead board of HackerRank, and then, she found the book to read:

https://algo.is/
competitive programming course

https://sites.google.com/site/stevenhalim/

Free download - version 1

Competition course


Julia is looking for a book talking about suffix array etc. advanced data structure. She found one today.

Write down some great ideas after reading. 

1. 10 terms Julia's favorite from the book:
1. Simple array that is pre-preprocessed with Dynamic Programming - Data Structure term (page 7)
2. Page 11, a form of Hash Table - ‘Direct Addressing Table’ (DAT) 

2. Page 8 Question:
2. Given a list of integers L of size up to 1M items, determine whether a value v exists in L?

(More details in Section 2.2.1).

Page 16 - Balanced Binary Search Tree (BST): C++ STL <map>/<set> 
Java TreeMap/TreeSet 
argument: implement a bug-free balanced BST like AVL Tree or Red-Black (RB) Tree is tedious and hard to do under time constrained contest environment. 

3. Look into those typical problems, first, remember the terms - Page 17 - Page 18 
Spend 30 minutes for each problem - warmup, and get traditional problems into daily routine - talk, warmup, and study some implementation using C# as well. (9/11/2016 - 1:21pm)

Programming exercises to practice using basic data structures and algorithms (with libraries):
• Static array, C++ STL <vector>, <bitset>, Direct Addressing Table
1. UVa 482 - Permutation Arrays (simple array manipulation)
2. UVa 594 - One Two Three Little Endian (manipulate bit string easily with <bitset>)
3. UVa 11340 - Newspaper (Direct Addressing Table)

• C++ STL <algorithm>
1. UVa 146 - ID Codes (use next permutation)
2. UVa 10194 - Football a.k.a. Soccer (multi-fields sorting, use sort)
3. UVa 10258 - Contest Scoreboard (multi-fields sorting, use sort)

• Sorting-related problems
1. UVa 299 - Train Swapping (inversion index3 problem solvable with bubble sort)
2. UVa 612 - DNA Sorting (inversion index + stable sort)
3. UVa 10810 - Ultra Quicksort (inversion index - requires O(n log n) merge sort)
4. UVa 11462 - Age Sort (counting sort problem, see [4])
5. UVa 11495 - Bubbles and Buckets (inversion index - requires O(n log n) merge sort)

• C++ STL <stack>
1. UVa 127 - “Accordian” Patience (shuffling <stack>)
2. UVa 514 - Rails (use <stack> to simulate the process)
3. UVa 673 - Parentheses Balance (classical problem)
4. UVa 727 - Equation (Infix to Postfix conversion)

• C++ STL <queue>
1. UVa 336 - A Node Too Far (<queue> used inside BFS, Section 4.3)
2. UVa 10901 - Ferry Loading III (simulation with <queue>)
3. UVa 11034 - Ferry Loading IV (simulation with <queue>)

• C++ STL <map>/<set>
1. UVa 10226 - Hardwood Species (use <map>)
2. UVa 11239 - Open Source (use <map> and <set> to check previous strings efficiently)
3. UVa 11308 - Bankrupt Baker (use <map> and <set> to help managing the data)
4. UVa 11136 - Hoax or what (use multiset in <set>)

• C++ STL priority queue in <queue>
1. UVa 908 - Re-connecting Computer Sites (priority queue in Kruskal’s, Section 4.4)
2. UVa 11492 - Babel (priority queue in Dijkstra’s, Section 4.5)
3. LA 3135 - Argus (Beijing04)

Find a website about Ultra quicksort:

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1751


Nov. 24, 2016
C# book reading:


Thursday, September 1, 2016

A drill - Leetcode solution code study

Sept. 1, 2016

 Code reading first, coding writing follows. So Julia designs a drill for her to work on Leetcode algorithm daily. Just use Visual studio to go over the best code in C++ for Leetcode solution, written by a computer science Ph.D.. Find the best code (so many solutions, this one definitely is top 1 in thousands), use the code to train herself in the thinking.

 Give it a try, and see if it works out or not.

Inside github, search HackerRank, find this: (MSFT, top performer, ACM/ICPC coaches (2010 - 2012), with time spent for each algorithm)

https://github.com/jianminchen/LeetCode-17

Julia spends hours, days to work on a solution, a best performer is there to play it with less than 20 minutes.

The practice is to find things to improve, one algorithm a time. Or find things to learn, write down one by one.

Review algorithms:
1. LC98    validate binary search tree - Sept. 12, 2016
2. LC61    rotate list
3. LC200  number of islands



Wednesday, August 31, 2016

CSS - responsive background image

August 31, 2016

Spent over 3+ hours to work on the research on CSS - responsive background image. Take time to learn CSS and enjoy the workout.

Learn to design a nice menu page with header and footer, with responsive background image, it is a fun journey. How to make it pragmatic solution? Julia has her own journey recently.

Step 1:
Study the idea to design CSS -

https://www.smashingmagazine.com/2013/07/simple-responsive-images-with-css-background-images/ 

use a span element, and set padding top to aspect ratio of image -

Step 2: box model issues - footer is cut off, and background image is cut off on mobile devices.

1. Read stackoverflow article to address the issues -

http://stackoverflow.com/questions/8916148/ipad-iphone-full-page-background-image-shows-cut-off-screen-shot-link-includ

https://dev.opera.com/articles/an-introduction-to-meta-viewport-and-viewport/

2. study the blogs:

How div container behaves - box model -

http://stackoverflow.com/questions/9061520/auto-height-on-parent-container-with-absolute-fixed-children

problem:  here is the website:
http://jsfiddle.net/dPCky/

Here is the solution blog:
http://jsfiddle.net/blowsie/dPCky/1/

http://www.gsmarena.com/lg_nexus_5-5705.php

The lesson Julia learned is that body is the container - root of DOM tree. The height of body should be bigger than inside elments' height. Otherwise, footer is missing since it is out of box of DOM element - body.

Editorial Notes:
Learn how to search github more often:
1. CSS reading blog:
https://github.com/YuanXiaosong/Front-End-Interview

A small research on HackerRank - seek excellence

August 30, 2016

  Go over HackerRank world code sprint lead board, from ranking 230 to 430, go over one by one, and see how Julia can make it in short future. To be one of them, what is missing, what should learn from those people.

  From different backgrounds, computer professors, Google employees, Microsoft employees, and a lot of others, university students. But, most of them attended more than 4 contests, and showed strong interest in things:

  1. Some of them take Coursera courses - More than 10 of courses
  2. Some of them document their HackerRank contests on Linkedin profile.
  3. Some of them are excellent coding, one of them finishes Leetcode over 200 questions.
     Julia just forked solution in the next minute, will study the code.
  4. Some of them are from Intel, Intuit, Cisco, etc.
      Read code, study styles, that is Julia's favorite thing to do.

  Julia has to take into consideration, work on difficult level algorithm on HackerRank. She prefers to stay in easy, medium level up to August 31, 2016.

Blogs to read:

1. practice, drills, strategies - a computer science course to help
https://cs.illinois.edu/news/illinois-team-advances-icpc-world-finals
http://goo.gl/ZdJ8C0

2. https://algo.is/
competitive programming course

https://sites.google.com/site/stevenhalim/

Free download - version 1
http://www.comp.nus.edu.sg/~stevenha/myteaching/competitive_programming/cp1.pdf

http://linc.nus.edu.sg/search~S16?/aVerdu%2C+Elena./averdu+elena/-3%2C-1%2C0%2CB/frameset&FF=averdu+elena&1%2C1%2C

Julia is looking for a book talking about suffix array etc. advanced data structure. She found on today.

2B:
http://www.stanford.edu/~liszt90/

Interview:
https://www.youtube.com/watch?v=tZRWUesgqFc&feature=youtu.be

2C: questions and answers about practicing:
https://www.quora.com/profile/Bohdan-Pryshchenko

2. Top 50 - blogs about programming competition:
http://sd-invol.github.io/Archives/
http://sd-invol.github.io/
http://sd-invol.github.io/2015/02/14/Palindromic-tree/

Talk about algorithms - in contest - SRM641 - ?
http://sd-invol.github.io/2015/01/10/Topcoder-SRM-641-650/

SRM
https://github.com/jianminchen/TopCoder

3. Read the algorithm  - enjoy time to read
https://threads-iiith.quora.com/

Tutorial on Trie and example problems

4. Look into those contests the contestant chose to take part in - anything interesting?

26 gold medals - read code first
https://www.hackerrank.com/rantd

5. Read one algorithm first:  Excellent blog about algorithm - great sharing!

https://aleigorithms.wordpress.com/

https://aleigorithms.wordpress.com/2016/03/11/hfcq2016-problem-analysis/

6.  Choose one of algorithms to work on this week:
http://basicjahid.blogspot.ca/search/label/Algorithm%20Tutorials

7. MCSD programming in C#
https://www.microsoft.com/en-us/learning/exam-70-483.aspx

Monday, August 29, 2016

Beautiful 3 set - code study

August 29, 2016

Plan to work on difficult level algorithm - world code sprint #6. Plan to work on world code sprint some day, be able to solve difficult/ advanced algorithm.

https://www.hackerrank.com/contests/world-codesprint-6/challenges/beautiful-3-set

Will come back very soon to work on this algorithm.


Sunday, August 28, 2016

C# StringBuilder Class - study

August 28, 2016

Work on C# StringBuilder class APIs.

https://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx

Will work on the APIs 30 minutes a time. Try to memorize all of them, understand the design in detail: function signatures, overload, optional arguments etc.


Bonetrousle - HackerRank world code sprint #6 - Time complexity

August 28, 2016

Worked on the algorithm over 3 hours, Bonetrousle. HackerRank code sprint #6.

 Julia started to train herself to get smart on algorithm problem solving - contest level. First and big lesson is to put the time complexity analysis first - she experienced the pain and valued the lesson she learned through 3+ hours.

 Editorial notes from HackerRank:

https://www.hackerrank.com/contests/world-codesprint-6/challenges/bonetrousle/editorial

Will work on this blog later!

Come back on Sept. 1, 11:15pm.

The problem is about loops, and let us work on the example used in the editorial notes:

N = 15, K = 8, B =3, in other words, find 3 distinct numbers from set {1, 2, ..., 8}, and the sum is 15.

First idea: brute force one 
Brute force, 3 number, each one is chosen from 1-8, 3 time, then, simple combinatorics: 8 * 7 * 6, K (K-1)(K-2), , the order does not matter, so it is should C(8,3).

As we know, N < 10^18, K<=10^18, so, Julia, you like to make any points, try to avoid any brute force solution like the above.

Second idea: How low it can be? 
Find B numbers, as we know, from the example,
N = 15, K = 8, B = 3, there are more than 1 solution.

But, there is one definitely taking minimum time. That is to find maximum number in B number set first, and it takes O(1) time. Then, in decreasing order, find one by one. The total time can be  small as O(B).

Simple math, we can analyze first if N is in the range of minimum value and maximum value range first.

if B > K, not possible;

Assuming B <= K,
Minimum value = 1 + 2 +... +B,
Maximum value = K + (K-1) + (K-B+1)




C# string class - API study

August 28, 2016

Previous blog about string class study for C#, Java, JavaScript, C++:

http://juliachencoding.blogspot.ca/2016/07/c-c-javascript-java-string.html

Go over all APIs in string class - C# programming language:

https://msdn.microsoft.com/en-us/library/system.string_methods(v=vs.110).aspx

40 APIs - Go over it 30 minutes a time - start to memorize them: function signature etc.

Clone
Compare
CompareTo
Concat
Contains
Copy
CopyTo
EndsWith
Equals
Format

GetEnumerator
GetHashCode
GetType
GetTypeCode
IndexOf -        (8 overloaded version)
IndexOfAny    (3 overloaded version)
Insert
Intern
IsInterned
IsInterned

IsNormalized
IsNullOrWhiteSpace
Join (5 overload)
LastIndexOf (8 overloaded version)
Normalize
PadLeft
PadRight
Remove
Replace
Split (6 overloaded version)

StartsWith (3 version)
Substring
ToCharArray
ToLower
ToLowerInvariant
ToString
ToUpper
ToUpperInvariant
Trim
TrimEnd

TrimStart








Bonetrousle - HackerRank world code sprint #6 - code study

August 28, 2016


Study 5+ C# submission code, put some notes here as well.

1. Use Queue, using structure, excellent code to study -
C# submission to study.

 rank before 190/ 5332




Great workout using Queue, Julia came out this idea through practice, but she could not write down code. She tried to write recursive function.

2. a while loop, less than 40 lines code
C# submission

rank before 200/ 5332, score around 250/380

3. C# submission

4. C# submission

5. Great code! C# submission


rank in range of 270 - 300/ 5332 participants (score in range of 

180- 200/380)

Time to go over C# string class: 


C# string class join method



Motivation talk:


work hard! 

Julia ranks 1112 on world code sprint #6. If she can work out the algorithm - Bonetrousle, based on her current score is 100, she can score another 50, from score of 100 to 150, then, she can get into top 1100 to top 550 - 650 ranking. 

Bonetrousle - HackerRank world code sprint #6 - Practice 3

August 28, 2016


Practice 3:

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

Highlights of practice:
1. Add hashset to filter out the boxes

Statistics:

Score 0 out of 50.


Bonetrousle - HackerRank world code sprint #6 - Practice 2

August 28, 2016

Problem statement:
https://www.hackerrank.com/contests/world-codesprint-6/challenges/bonetrousle


Try to make any progress on timeout issue, wrong answers issue. Add additional checking to shorten the time to do processing:

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

Highlights of practice: 
1. line 113

Statistics:
score 0 out of 50 points.

Bonetrousle - HackerRank world code sprint #6 - Practice 1

August 28, 2016

Problem statement:
https://www.hackerrank.com/contests/world-codesprint-6/challenges/bonetrousle

Julia was naive on planning, management of time, tried to solve this algorithm, without any hesitation. She tried to score any point above 0, found the idea to write code using stack, but with additional 2+ hours to review code, stayed overnight, from 12:00am - 2:45am, a brute force solution. She did not make any (over 10 test cases: 5+ wrong answer, 4+ time out). So, she wrote down the experience to celebrate her weekend, over middle night struggling with an algorithm.

Share some statistics of world code sprint #6 workout:
Current Rank: 1112 - score 100/ 380 (score first 4 algorithms full score)

First practice:

Use stack, brute force, each box has two choice, join or skip. She tried to implement the brute force solution first, and then, she recalled the previous work on algorithm Leetcode: phone number:

https://gist.github.com/jianminchen/872bf70039fa8c61ff208b34a591c8ec

Only pass the test cases provided in the problem description.

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

Statistics:
score 0 out of 50 points.

Brute facts:
A brute force solution does not score any points - even pass the basic test case - test case 1.

Actionable Item:

Write a blog about this algorithm, document the importance of time complexity analysis; how to plan to spend time to work on a solution.

http://juliachencoding.blogspot.ca/2016/08/bonetrousle-hackerrank-world-code_75.html

Abbreviation - HackerRank world code sprint #6

August 26, 2016

Problem statement:
https://www.hackerrank.com/contests/world-codesprint-6/challenges/abbr


C# practice:
https://gist.github.com/jianminchen/12e7c74b57c5780a069b0e9df66f77c3

Study editorial notes about the algorithm, using dynamic programming, a DP solution.

Study other submissions through HackerRank.

Saturday, August 27, 2016

Blog writing - aiming for good writing talent

August 27, 2016

  It is a nice journey to write a lot of blogs in last 12 months. Julia learns to handle a lot of stress, spend a lot of time to proofread, feel headache about the content, organization of ideas etc. Sometimes, she notice that she writes something she does not know, she does not have best solution, since she is still developing, in the cooking process. Or she just pushes herself, just do it. It may be an interesting topic, start first, come back to work on.

  What is about good writing talent? It is not just English writing, also about communication skills, inspiration to share, good language skills.
  A true short story about her personal experience:

  She went through 3 IELTS test in 2008 from June to August in order to score 2 of 7/ 9 on English (reading, writing, speaking, listening) - apply Canadian immigration. She did 3 tests in 3 months, because Fort Lauderdale test center only gives one test a month. She even filed an appeal against the scoring result after 2nd test, costed her $160 dollars, same amount as the test fee. She practiced old tests in the time range of 3 month - 3 hours for one test, she did again and again.

More detail about IELTS:
http://www.ielts-blog.com/ielts-results-competition-winners-2008/
  End of the true short story.

  And then, in 2015, Julia learned that in order to
get best result of
build up some writing talent continuously in long term,
grow up from a junior software developer to talent programmer,
she has to write down her coding practice everyday, speak out her unique experience, ideas/ practice log, show her progression, weakness, highlights, one step a time, one practice a time. There is no way to avoid hard work, embrace it. She learns from her favorite tennis sports. 

  So, she try to push herself to work on writing. Being a good software programmer, writing code is much more challenging. 

Here are some ideas:

  From blog - how to improve your blog writing skills 

 1. Make writing a habit
As the old saying goes: Practice Makes Perfect.
 2. Get back to basics
 3. Proofread your articles
 4. Remove the filler - tighten your article and make it easier to read
 5. Evaluate your writing
 6. Be an avid reader
 passionate writer should be a passionate reader.
 7. Establish good writing habits

Google search keyword:
blog writing help English writing

Second blog - Improve writing skills


Notes:

1. Brush up on the basics

2. Write like it's your job
Keep practising, writing is no exception.
diminish your fear of the blank page (or blinking cursor)
develop a unique style
even if nobody reads it, keep writing.

3. Read like it's Your Job
reading on a regular basis
pay attention to sentence structure, word choice, and how the material flows.

4. Find a writing partner
a solitary activity - writing?
cast an eye over your work?
spot mistakes that you may overlooked

5. Join a workshop or take a night class - not applicable right now

6. Dissect writing that you admire

7. Imitate writers you admire
use humour to spice up dry topics?
use pop culture references to make their work entertaining and useful?

8. Remember that outlines are your friend - outline?
solid outline plan? When, who, what, where, why, how? 7 W

9. Edit your work ruthlessly

be your own harshest critic?
editing is a tough skill to learn for beginner?
writing or rewriting?
the cold, hard eye of an editor will serve you well?
discipline to eliminate extraneous words?
resist the temptation to wax lyrically and get to the point?

10. Accept that first draft are almost always crap

write down on paper first, clean up later. Iterative process. Do not beat yourself up.

11. Find a good patient editor

12. Eliminate unnecessary words

13. Take a stroll down memory lane

14. Don't be afraid to say what you think

15. Do your research

16. Don't take weeks to finish a post

Actionable items:

Try 3 ideas first:

14. Don't be afraid to say what you think
testimony:
Share personal IELTS test experience in 2008 


Html, CSS style guideline study

August 27, 2016

 Always work on code guidelines first, then write more code everyday.

 Plan to spend 2+ hours to study html, CSS code guide.

http://codeguide.bootcss.com/

https://google.github.io/styleguide/htmlcssguide.xml



Java Design Pattern - code study

August 27, 2016

 Plan to spend 3+ hours to go over some Java Design Pattern.

https://github.com/jianminchen/java-design-patterns


Programming Principles - study

August 27, 2016

 Through leetcode practice Algorithm 125 in August 2015, Julia noticed that she still stumbled badly on easy question. Because ..., wild guess?:-) she does not have good understanding of programming principles.

 She wrote blogs about the practice of Leetcode 125, 11 practice, through continuously hard word through 3 days, she finally came into realization of best solution - extract one more function  called removed noise. She read the code written in C++ in her github forked solution more than 6 months ago. She could not find the best solution through google/ bing, and she studied stackoverflow related articles more than 2 hours, but she just did not come out the idea.

  Apply Separation of concerns principle? optimal solution to Leetcode 125. 

 The above is enough for her to dedicate herself to read more about programming principles.

Programming Principles

https://github.com/jianminchen/programming-principles

 Plan to work on reading 3+ hours, write down some notes here.


Thursday, August 25, 2016

CSS - Responsive background image

August 31, 2016

 Spent over 10+ hours to work on responsive background image issues. So, Julia likes to spend time to serve herself better using CSS.

Google keyword search:

 css responsive background image


Code study: Leetcode blogs

August 25, 2016

 Compile a list of Leetcode blogs to read, 10 minutes a time, look for excellence through blogs:

1. http://bangbingsyb.blogspot.ca/   (Microsoft, C++)
2. http://fisherlei.blogspot.ca/          (facebook, blogs, C++)

C++ solutions in github:
1. https://github.com/jianminchen/leetcode-1 (C++, ex-amazoner)
2. https://github.com/liaoxl/leetcode/tree/master/code  (Neteaze, C++, China)
3. https://github.com/jianminchen/Leetcode-13  (UBC, C++)
4. https://github.com/jianminchen/myleetcode (China, Microsoft, C++)
5. https://github.com/jianminchen/LeetCode-IIII  (C++, HackerRank Silver medal)
6. Inside github, search HackerRank, find this: (MSFT, top performer, with time spent for each algorithm)
https://github.com/jianminchen/LeetCode-17

Java solutions in github:
1.  https://github.com/jianminchen/LeetCode-Java-Solutions
2.  https://github.com/jianminchen/LeetCode-Java-Solutions  (Java, computer PH.D.)
3.  https://github.com/jianminchen/LeetCode-Sol-Res  (Nine chapter etc., Java)
4.  https://github.com/jianminchen/leetcode-3   (Java solution, Googler)

C# solution:
1. https://github.com/jianminchen/LeetSharp
2. https://github.com/jianminchen/Qilu-leetcode
2. https://github.com/jianminchen/LeetCodeInCSharp
Motivation talk: 
1. Sometime, google, bing search do not provide best source code, so, it is time to look up github forked solutions. 

Friendly remind: 
Julia, you should use github's search - use keyword: Leetcode to find solutions - 

2. Look for optimal solution, do not miss the best solution in practice of Leetcode algorithm. Do not rush, try to go through all kinds of practices, search for great ideas out there. Get the best idea to practice. One algorithm a time. 

3. Follow more people through github, easy to fork leetcode solutions. Sometimes, it is hard to tell best code, just get some code running first, write first C# practice, and then, ideas will come, what to search, issues etc.

4. Evaluate practices (junior/middle/senior level practice), and then compare to 5-10 practices. (0-3 junior practice, 4-7 middle level, 1-2 optimal solution, senior level practice)

4. Look up stackoverflow to get more ideas, specially from high reputation/ high voted opinions, terms to know when practicing Leetcode algorithms. Try to expand the things to work on through the practice, one algorithm can bring good study about coding style. See the blog:
http://juliachencoding.blogspot.ca/2016/08/leetcode-125-valid-palindrome-summary.html


5. When practicing Leetcode questions, try to work on more through the practice. There is an idea that if you work on thoroughly on one problem a time, you may be able to solve unseen problems as well.

Actionable Items:

1. Study programming principles:
Programming principles
https://github.com/jianminchen/programming-principles









Leetcode 348: Design Tic-Tac-Toe

August 25, 2016
Problem statement:

Design a Tic-tac-toe game that is played between two players on a n x n grid.
You may assume the following rules:
  1. A move is guaranteed to be valid and is placed on an empty block.
  2. Once a winning condition is reached, no more moves is allowed.
  3. A player who succeeds in placing n of their marks in a horizontal, vertical, or diagonal row wins the game.
Will work on the algorithm very soon. 

System Design: Design a URL shortening service

August 25, 2016

Problem statement:

Design a URL shortening service

  • What do you think the requirements are?
  • What is your high level design?
  • You might be asked to implement interesting portions
  • How do you test it? 
Will work on the design very soon.

1. Read the website first:  5 - 10 minutes

stackoverflow.com - how do short urls services work

2. Hired in tech website - the system design process

Step 1: Constraints and use cases
Step 2: Abstract Design

Start from step 1:

System constraints (Do you clarify?)
Use cases ( the list to satisfy?)
Scope system (agree?)

Gather requirements -> design a solution to cover them well.

Use cases:
1. Shortening:
2. Redirection:
3. Custom Url
4. Analytics
5. Automatic link expiration
6. Manual link removal
7. UI or API

And then, discuss and exchange ideas with requirements:
For example, add one more use case 4, and move 4 - 7 out of scope, not for now.

1. Shortening:
2. Redirection:
3. Custom Url
4. High availability of the system

Out of scope: 
4. Analytics
5. Automatic link expiration
6. Manual link removal
7. UI or API

Constraints: 

Top 10 shorten URL services:

Math to figure out, for example: 

15 billion new tweets in twitter, 

All shortened URLs per month: 1.5BN - 10 percent
Sites below the top 3: shorten 300M per month

1. New urls per month: 100MLN - 100 millions request to shortening
2. 
3. 
4. 
20% urls generate 80% traffic -> 1BN request per month -> 10% shortening, 90% redirection.

4. Requests per second: 400+ requests per second (40: shortens, 360: redirects)
5. 6BN urls in 5 years -
6. 500 bytes per URL (100 to 1000 characters per URL)
7. 6 bytes per hash
8. 3TBs for all urls, 36GB for all hashes (over 5 years, not 10 years)
9. how much data goes through each second?
    New data written per second: 40 *(500 + 6): 20K
10. Data read per second: 360 *506 bytes: 180K

scope the problem beautifully - it takes a while, but 15 minutes in the video, with practice, it takes 5 minutes to clear up everything.

Follow up 


Sept. 3, 2016

Spend 2 hours to watch the video, hiredintech.com, the video link is here. System design - scalability, the link is here.


Take some notes here.




Linked List Queue

Problem:
Implement a Queue using a linked list.

Will come back soon.


Array Queue

August 25, 2016

Problem statement:
Implement a Queue using a circular array.

Read circular array:
http://www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/8-List/array-queue2.html

Will come back very soon!