Wednesday, June 22, 2016

Leetcode 139: word break I - 3+ practices

June 22, 2016

Work on leetcode 139 - word break I

Problem statement:
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
For example, given
s = "leetcode",
dict = ["leet", "code"].
Return true because "leetcode" can be segmented as "leet code".
Programming skills is like muscle, if you do not maintain it, it will go back to fat. When Julia tries to stretch DP muscle, she found out that she has nothing to stretch. She has to work on it, build up by hours, build up again. Leetcode 139: word break I (medium).
Julia read the code/ solution, but she could not figure out in detail, specially for those two loops - for DP algorithm. 
1 hour, play with 2 test cases. 
3 practices using C#; Set up a test case, run the code, and then, understand the algorithm.

Same code, different test cases
1st practice:
https://gist.github.com/jianminchen/f763ce5033ea4b152c7a56aaf98b7075

2nd practice:
https://gist.github.com/jianminchen/a1bafb4271b8bbdb18b92d0b3dad913e

3rd practice:
https://gist.github.com/jianminchen/bd9301c3ad38d801001d1d66a08256fe

Let us walk through a test case:
string test = "abcd",
and dictionary string array: {"a","bc","d"}

We know that, "a" can be constructed by word "a" in the dictionary.
"ab" cannot be constructed by the dictionary.

Now, what we can do to work on substring "abc", assuming that "a", "ab" are processed already.

How to approach the problem?
Use dynamic programming, reduce the work to minimum.

abc, so 'c' is the new comer, assuming that "a" and "ab" have been processed. By debugging the code, Julia put together the following comment:

so, step 1, "ab" cannot be constructed by the words in dictionary, so it does not matter if 'c'  is in dictionary. 
   Use array bool[] dp to store the cached value; 
  
   Cannot conclude that "abc" can be constructed by words in dictionary, need to go through all possible new words: {"c", "bc", "abc"}

    step 2, backward one more char, new word: "bc", 
 "a" is in cache - dp[1] = true, 
 "bc" is in the dictionary. 
 so,  "abc" can be constructed by words in dictionary. 
 Stop here, break the loop.     

    At most there are 3 words ending at 'c':
    "c",
    "bc",
    "abc",
    All other substrings are the substring of  "ab", assuming that DP is used, so no need to worry about.

4th C# practice:
https://gist.github.com/jianminchen/36de4c46292e79290af95098dfee3cb0

Question and Answer:
1. What is most time consuming part in coding?
Julia spent over 20 minutes to figure out what should be looped on - line 80, it is hard to figure out
meaningful ways to loop. She tried a few of ideas, then, she chose to loop on the position of right string.

   "abc",
   i = 2, then, 3 things are tried:
  1.  "ab", "c"
  2.  "a", "bc"
  3.  "",   "abc"

  two strings are in each case, right string's starting position in the original string "abc"
 line 80    for( int pos = i;  pos >= 0; pos--)
  i = 2, "c"
  i = 1, "bc"
  i = 0,  "abc"

4th C# practice:
 https://gist.github.com/jianminchen/36de4c46292e79290af95098dfee3cb0

Spend 10 minutes to write the program again.
5th C# practice:
https://gist.github.com/jianminchen/9766aea70c9015fabbea98fb71b56d6d

hightlight of changes:
1. line 41 - variable name is changed from "left" to "existingWord", existingWord is already processed, which can be looked up through cache array - true/ false.
2. line 42, newWord, each time the new char is processed, there are ith words ending at position i.
Need to check if it is in word dictionary.
Comparison between 4th practice and 5th practice:
comment:

code:
4th practice:
1. Do not know only work on substring 0-i, length i+1 substring, bottom up approach as DP - dynamic programming.
2. Confuse with string left, right, why left string needs to check cache, and then right string checks word dictionary.

Read blog to review dynamic programming:
https://en.wikipedia.org/wiki/Dynamic_programming

Review a few concepts:
Principle of Optimality
optimal substructure
larger problem - sub-problems
Bellman equation - optimization literature names relationship
optimal substructure and overlapping sub-problems
Divide and Conquer   vs dynamic programming
Top-down approach vs Bottom-up approach

Word break I uses bottom up solution -

6th practice:
https://gist.github.com/jianminchen/29758bad5d56d54e87c2a6f52d057835
comparison line by line:
    6th practice                                             5th practice

7th practice:
second loop on DP algorithm, new word loop starts from start position from 0 to i, in ascending order, line 43. 
https://gist.github.com/jianminchen/2e56665d934f9b9cbc2f94adc8e567bb

Statistics:
Time spent:
2 hour +


Train insane or remain the same - focus on training!

Tuesday, June 21, 2016

ATP - Tennis Coaching - Sports coaching

June 21, 2016

  Julia spent 2 hours to do a small research on ATP player Novak and how he works very well with his coach - Boris Becker. Champions need  coach, how they select and work with their coaches?

  Spent time to watch the interview:

  Boris Becker on coaching Novak Djokovic
  https://www.youtube.com/watch?v=1a5w-LBot1c

  I like how relax the interview is, and Boris expressed his idea so clearly, so calm. Julia likes to learn how mental tough or focus Boris is to answer the interview questions.

  Justin Gimelstob Interview Boris Becker Part 2
  https://www.youtube.com/watch?v=FV4GUd60pjI&spfreload=5

 Julia coaches herself to be a better programmer, she pushes herself to write down her thought, and then, review, criticize her own writing/ thoughts, and then try to find what she is looking for - a coach makes difference.


Strength knowledge of data structures and algorithms

June 21, 2016

 20 minutes research on the topic - strength knowledge of data structures and algorithms.

https://www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms

Write down some notes.
Top coder website to read:
https://www.topcoder.com/community/data-science/data-science-tutorials/

Read the Quora question:
https://www.quora.com/What-are-the-algorithms-required-to-solve-all-problems-using-C++-in-any-competitive-coding-contest

86 algorithms: (get to know the algorithms - memorize the name first)
https://www.quora.com/What-are-the-10-algorithms-one-must-know-in-order-to-solve-most-algorithm-problems/answer/Pratyush-Khare-1?srid=iGPI&share=1

http://www.ideserve.co.in/

http://www.ideserve.co.in/learn/lowest-common-ancestor-of-two-nodes-binary-search-tree

https://docs.google.com/document/d/1_dc3Ifg7Gg1LxhiqMMmE9UbTsXpdRiYh4pKILYG2eA4/edit?pref=2&pli=1

Algorithm webpage: in Russian, code is good:
http://e-maxx.ru/algo/

Julia, if you miss the good lecture, then just click the link:
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/video-lectures/




Plan to learn some technologies:
List can be very long, ...
 Angular JS, Bootstrap, Entity framework, Rest API, AWS, Azure ...


Monday, June 20, 2016

Leetcode 329: Longest increasing path in matrix

June  20, 2016


problem statement:
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).
329. Longest Increasing Path in a matrix

Example 1:
nums = [
  [9,9,4],
  [6,6,8],
  [2,1,1]
]
Return 4
The longest increasing path is [1, 2, 6, 9].
Study the code written in Java:
1st practice using C#: 
Question and answer:
1. How is the practice? 
The study was very good. DFS - using recursive call, and then, tricky part is to use memorization to 
avoid duplicated calculation. 

2. Talk more with an easy example, therefore, next time you will not forget the problem after 
a few months. 
Answer: Will write something here. 



1. Talk about node row = 2, col =1, value is 1, denoted as start1,  3 neigbors, left (value 2), right (value 1), up(value 6)
2. Try to avoid loops - base case checking, always go to the node value >= current value >= start node '1'
3. Also, if neighbour node left (value 2) has maximum increasing path in matrix n, then, what we can know:
   value 1 < value 2, then, start1's longest path at least 1 + value2's longest increasing path. Need to check other 2 
  neighbors to see if it is larger value

    left neighbor (value 2)'s longest increasing path in matrix 2->6->9, length is 3;
    right neighbor (value 1)'s longest increasing path in matrix 1->8, length is 2; 
    upper neighbor (value 6)'s longest increasing path in matrix (actually 2 of them, 6->9 or 6->8), length is 2. 

4. DFS algorithm can be set up using recursive function; also, there are total 3*3 = 9 nodes in the above matrix, 
    each node's increasing path in matrix should not count more than once. 
    For example, nums[0,0] = 9, is maximum value of matrix, so the longest path = 1. 

    Let us put a sentence together. How about the following:
    Be greedy, check your neighbors (at most 4), and find maximum one with longest increasing path in matrix, and then use the path
to build your own. The value is 1 + that neighbor's problem, where the recursive function is constructed. 

5. The design of algorithm - brute force solution - how many paths in the matrix - n^4 = n x n x n x n; filter out non-
increasing path, then find maximum value - not efficient
6. For each node in matrix, find its longest increasing path in matrix, nxn nodes, each node, DFS algorithm is applied. 
    at most nxn node is checked about increasing order. <- try to reason the time complexity -> ...
    Will be less than n^4. 

7. Prepare a check list for the design:
    1. Run time issue - index out of range - array - boundary check 
        loops - always go to bigger value - no loop 
    2. time complexity - nxn node, each one does DFS; each DFS, at most 4 n^2 comparison of value. 
    3. space complexity - use extra array nxn to store bool value - memorization  
    4. value is bigger/ smaller / 0, 0 - not possible, at least 1, miss count - recursive, should be easy. 
    5. Brute force solution and its issues - more time consuming etc., duplication calculation    

Most important discussion: 
find the idea to store in extra array: 
1. Extra array to store the length of "longest increasing path in matrix" for each node in the array - (working idea)
2. Extra array to mark the node is visited or not -  (not enough for calculation!)

 denote DFS function to calculate the longest increasing path in matrix, then starting from start1, the function will be

left->left->up->up, in other words, from 1->2->6->9, and then, 
up->right,    1->6->8   
up-> up,       1->6->9, 
the visiting order of neighbors is left, down, right, up.
anti-clockwise, left, down, right, up  - line 116 - 120
So, the cache value of (2, 1) is 4, longest path is 4 (1->2->6->9); and 6 nodes in matrix are calculated and saved with 
cache value - 2 matrix(2,0), 6(1,0), 9(0,0), 6(1,1), 8(1,2), 9(0,1), the order of saving is 
9(0,0),          - 0 neighbor
6(1,0),          - 1 neighbor
2 matrix(2,0) - 1neighbor, value 1
6(1,1)
8(1,2)            
9(0,1)
6(1,1)   - 2 neighbors, comparison 1 vs 1 
1(2,1)   - 2 neighbors, comparison 3 vs 2

Use stack to help to track the order: 
start1 node, 2 neighbors
go to left neighbor first, 
      push to stack, 2, 6, 9
no down neighbor, skip right
then go to up neighbour, 
     ...


Statistics: 
Time to work out order of calculation cache value in the above list takes more than 10 minutes. 

Two motivations to work on reasoning and analysis:
1. Leetcode 329 is hard
2. Being able to write down bug free, executable code in 20 minutes. 

  3. Study more solutions from others, and then, practice it using C#. Study one using C++. 
C++ solution:


To be continued. 

Sunday, June 19, 2016

Rest Fundamentals - pluralsight.com

June 19, 2016

 Plan to spend 3 hours to take this course:

  Rest Fundamentals

Lecturer:
http://app.pluralsight.com/author/howard-dierking

Plan to study 3 hours:

Five Essential Tools for Building REST APIIs

by Elton Stoneman

Reading:


https://msdn.microsoft.com/en-us/library/jj819168.aspx



Go over Rest API example, learn the basics of Rest API ... 

http://www.asp.net/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api

Rest API project - developing a REST web service using C# - A walkthrough 

http://www.codeproject.com/Articles/112470/Developing-a-REST-Web-Service-using-C-A-walkthroug

http://www.codeproject.com/Articles/21174/Everything-About-REST-Web-Services-What-and-How-Pa

http://www.codeproject.com/Articles/21258/Everything-about-REST-web-services-what-and-how


https://www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms

http://stackoverflow.com/questions/671118/what-exactly-is-restful-programming  (20 minutes reading)

 RSET is a lightweight alternative to mechanisms like RPC (Remote Procedure Calss) and WEb Services (SOAP, WSDL, et al.). 

Saturday, June 18, 2016

.Net programming technologies

June 18, 2016

Spend 20 minutes to work on a small research, what .NET technologies are popular in the Vancouver market. Learn advanced technology, reduce time to do development and maintenance.

indeed.ca
equinox:
                 AngularJS, jquery, json
                 Soap/ XML/ XSLT/ XSD/ WSDL
                 LINQ

Health Employers Association:
                  MVC, Ext.Net or ExtJS

  MCSD, MCPD for web and desktop application, database and integration service.


LINQ Fundamentals - pluralsight.com

June 18, 2016

Work on course - LINQ Fundamentals - pluralsight.com - 4 hours courses -

June 18, 2016 11:43am - 2:43pm

Manipulating Data
  object data (generics, algorithms)
  relational data (ADO.net, SQL)
  XML data (XmlDocument, XPath/ XSLT)

Language Integrated Query (LINQ) works for all 3 kinds of data -

Standard Query Operators:
   Defined in the System.Linq namespace
   Work on any IEnumerable<T>
   CLS compliant (generics required)


LINQ's Extensibility
Operator extensibility

Provider extensibility
   A LINQ provider is a gateway to query-able types:
    PLINQ, LINQ to LDAP, LINQ to Flickr, LINQ to Amazon

LINQ to Objects
  Replace foreach loops and other iterative code with LINQ expressions:

Deferred Execution
Query expression does not execute until we access the result

LINQ to XML
   Not just another XML API
   XElement is the core class in the System.Xml.Linq namespace

Entity Framework
Entity framework provides a rich layer of object data services
Object services - LINQ to Entities and Entity SQL, Change tracking and identity management,
Serialization and data binding, and Connection and transaction management

Digging into C# Features For LINQ
   Extension methods
   Lambda Expressions
   Expression Trees
   Query Expressions
   Type Inference
   Anonymous Types
   Partial Methods

blogs:
http://www.albahari.com/nutshell/10linqmyths.aspx



Friday, June 17, 2016

LINQ Architecture - Pluralsight.com

June 17, 2016

Spend two hours to study the course LINQ Architecture by Scott Allen.

The lecturer webpage:

https://www.pluralsight.com/authors/scott-allen

Plan to study a few more LINQ courses:

1. LINQ Fundamentals
2. LINQ architecture
3. LINQ data access

Thursday, June 16, 2016

Leetcode 269 - Alien Dictionary - Practice 2 more times

June 16, 2016

Try to find a small topic to start to do some research every day at least 20 minutes, and then build up more later on.

Today topic is about writing algorithm code - problem solving, 1st writing (study other's code and understand) vs 1st writing (with simple test case with a diagram, more focus, a small problem):

Here is the cycle Julia goes through for Leetcode 269 - Alien Dictionary:

Coding process ->
choose an algorithm to code ->
study 4 or 5 solution from over 10 solutions ->
cannot learn an algorithm just by reading, stop reading ->
write C# code based on one of them (Java, or C++) ->
add comment, make code readable, debugging ->
code works ->
wait 10 - 20 minutes ->
draw a diagram to work on a simple test case ->
rewrite the code 2nd time->
big difference, a new story to write - it takes close to one hour -> 
interesting experience. ->
3rd rewrite ->
document the difference 

First blog of Leetcode 269 Alien Dictionary:

http://juliachencoding.blogspot.ca/2016/06/leetcode-269-alien-dictionary.html

1st good writing in C#:
https://gist.github.com/jianminchen/85129ed50ce597f896b0f0c5a2fa5586

Afterwards, work out a simple test case, and then, write down the graph with detail data structure and data, write code based on the picture. New ideas come out naturally to improve:


1st writing focusing on the above diagram: C# implementation
https://gist.github.com/jianminchen/58d80aa86a027af7a3e52277d15c3733

3rd writing using C# code:
https://gist.github.com/jianminchen/8d4c1f601bae0ca7ef27e470dfe1e636

Highlight the differences 3rd time:
1. line 26, base case is updated: words.Length <= 1 instead of <1
2. Add comments what to find in the function alienOrder
    1. spell error topological -> topoligical
    2. add nodes variable as part of graph
3. getNodes function -
    look into string.ToList() -> List<char>
    study HashSet.UnionWith() input argument and its type IEnumerable<T>
4. rewrite graphSetup function tasks from line 62 - 79
    explain very clearly to find an edge if there is one;
   what to construct in the graph.
   add precondition for the function.
5. rewrite the function comment for topologicalSort
6. missing line 163 - 164, run time error - array access - out-of-index

statistics:
Time spent: 3rd practice - more than 40 minutes

Quick tip:
{"wrt", "wrf", "er", "ett", "rftt"}

first char, comparison (all five words)            =>  w -> e -> r
third char comparison (first two words - "wrt","wrf")          =>  t->f
second char comparison (third, fourth words -"er","ett") =>  r-> t

So, the order is "wertf"

Comparison:
alienOrder - two things noticed documented in comment.
3rd writing - take some time to look up HashSet.UnionWith argument type: IEnumerable<T>, good time to learn something here.

Practice to write down what to do, in order to write good code, also need to explain what to do first. Good writing right side! Bravo!
Find a bug, 2nd version, left side, no edge case: return; should be continue; line 89

Also, write down tasks before writing code, good habit to train to focus on tasks when writing.

Use node in neighbors to make code more readable.


One algorithm a time. Take your time to master an algorithm.



Wednesday, June 15, 2016

LINQ - Language-Integrated Query

June 15, 2016

 Spend 20 minutes to work on C# Dictionary class extension method: All, Any method

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

 So, look into how many people are using LINQ:

equinox - C# .Net Application Developer,
Knowledge of, or a desire to work with:
  • AngularJS, jquery, json
  • Soap/XML/XSLT/XSD/WSDL
  • LINQ.
Canfor:  C#, VB.net, LINQ, JavaScript , HTML, XML, SQL, VBA, CSS

So, study more about LINQ. 

It is interesting journey, fast coding -> plan to memorize C# Dictionary API -> work on extension method All, Any -> start to learn LINQ -> C# .Net Application development

Actionable Items:

Do some research on LINQ - good study material - get some coding experience.

Put LINQ, Lambda expression code practice here - 10 - 20 of them first:
1. Practice debug - watch - lambda expression
https://gist.github.com/jianminchen/79608e80e1915ecdb5df118a54001086

2. review two string solution - use Any
https://gist.github.com/jianminchen/acedbb7cb86cf1c00131

3. Review two string solution - use Any
https://gist.github.com/jianminchen/50fc6b5a13b7d62dfa1d

4. Take two courses on pluralsight.com (June 17, 2016):
LINQ Architecture - 2 hours






Leetcode 269: Alien Dictionary

June 15, 2016

Leetcode 269 Alien dictionary

Choose to work on a graph problem - using Topological Sorting:

Study C++ solution:
http://www.cnblogs.com/jcliBlogger/p/4758761.html

Discussion about the problem description:
https://leetcode.com/discuss/53997/the-description-is-wrong

Study C++ solution:

https://leetcode.com/discuss/54024/straightforward-c-solution?show=54024#q54024


Java solution to study:

https://github.com/jianminchen/LeetCode-Java-Solutions/blob/master/269.alien-dictionary.java

http://www.cnblogs.com/yrbbest/p/5023584.html

Julia worked on C# code:
https://gist.github.com/jianminchen/07546625d828f63e762ba03b463fe8aa
line 75, 76, after queue.peek() is called, need to call dequeue. (dead loop)

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

Add more comment, where to be careful, to avoid bugs:
https://gist.github.com/jianminchen/47f516b54686080c3a68bc8c3f1d04cb

More comment, variable name refactor:
https://gist.github.com/jianminchen/85129ed50ce597f896b0f0c5a2fa5586

Read blogs:
http://www.geeksforgeeks.org/topological-sorting-indegree-based-solution/

Comparison between 2 versions:
variable name change: graph -> dependencyList, more meaningful. The graph has nodes, dependency list, inDegree array.
Change function name: getCharSet -> getNodes
Love those comment, so helpful to get start to coding...
Left side first implementation:
for(int j=0; j < shortLength; j++)
{
...
break;
}
confusing, not very easy to follow. line 154 - line 176, 22 lines of code. The big scope to handle. 

Also, this for loop is nested loop, too many lines of code inside. 
Replacement of while loop is short, only 3 lines of code. 

graphSetup -> what we can tell here? ... later!


Question and answer:
1. Can you work on a simple example to explain the idea of your solution?

Here is the warm up for topological sorting using two strings {"wrt","wrf"}:

Review previous blog:

Warmup practice:
statistics: 1 bug, more than 60 minute to write. Totally new program
https://gist.github.com/jianminchen/58d80aa86a027af7a3e52277d15c3733
a few changes to highlight:
1. line 24 - 26 add comment what to do about graph
2. line 49 - 65 motivation talk - help to design the function
    using the graph above {"wrt","wrf"}, help to write code
3. line 72 - 74 special case words length is 1
4. line 81 - line 85 use one pointer to slide forward <- more flat code
5. line 87 add comment - no edge -> very good comment
6. line 91 - 94 first writing with a bug - prev, curr, but prev twice

Here is the comparison file:
https://github.com/jianminchen/Leetcode_C-/blob/master/Leetcode269FirstAndSecondPractice.pdf

Statistics:
time spent: 3hours +



Tuesday, June 14, 2016

The Art of Speaking: Scott Hanselman

June 14, 2016

  Julia works on the most important skills - how to prepare a tech talk? She needs to work on a few of things: talk concise and stop; think about careful and make a short statement; focus on the main point.

  She spends 60 minutes to learn something through talk on Pluralsight.

   The Art of Speaking: Scott Hanselman

What do you learn through the talk? 

Coffee Script is much more readable compared to JavaScript, and also easy to get started with a few videos - quick study.

The design of talk is interesting, Julia, learn 3 things:
1. The example with 11 lines of code, written in coffee script, comparison to Java Script is very easy to follow;
2. The speaker knows how to give a very smooth talk - target wide range of users through the video watching.
3. The Delivery 14m8s - somewhere in first 5 minutes - Julia likes the talk about a loop, using business sense, explain what is going on, how easy things can go wrong: makes a mix of vegetables and chocolate, and then, go through them one by one. etc.


  To entertain the study, provide a video link about Microsoft azure network/ storage. Spent 10 minutes to watch the video:
https://www.youtube.com/watch?v=ZNgvZE0MLeo&list=PLHqk7I0X-_BYHuz0ZJt4HO8RXkh5nUjHG&index=2

Industry work vs academic research - blogs reading time

June 14, 2016

  Come cross the article about an engineer working for Google, a computer professor made a career change. Have some readings:

1. http://matt-welsh.blogspot.ca/2010/11/why-im-leaving-harvard.html

2. http://matt-welsh.blogspot.ca/2010/05/secret-lives-of-professors.html

3. http://matt-welsh.blogspot.ca/2014/01/getting-job-at-google-for-phd-students.html

4. Find a good topic to read:
http://matt-welsh.blogspot.ca/2013/02/grad-students-learn-how-to-give-talk.html

Julia's comment about how to give a talk:

Know your topic very well. I still remember the advice I got many years ago, "Do not waste other people's time - even it is 5 minutes. If you do not understand the topic, then stop talking!", "Reading related articles more than 10 hours, not working on a concrete example, coding/ experiment/ third party, it does not count!"

For example, Julia worked on binary tree least common ancestor more than 10 hours in less than 1 week, she wrote code more than 5 times, two solutions; definitely, she can give a talk over 15 minutes about the algorithm any time without any preparation, present the problem, draw some diagram, write some code, and then go over it, line by line, each variable, each executable path, discuss all kinds of bugs if there is a mistake. She knows 4-5 possible mistakes, because she made one by one, and then, spent more than half hour to fix one by one. It will be a fun talk.

http://juliachencoding.blogspot.ca/2016/04/find-lowest-common-ancestor-of-two.html

5. Code Review
http://matt-welsh.blogspot.ca/2012/02/my-love-affair-with-code-reviews.html

Julia's comment: 
Julia's favorite books: The art of readable code, clean code, and then, C++ code guidelines
And also favorite object oriented principles: S.O.L.I.D., good design principle - simple vs difficult.

Choose "Old school" or "new school", prepare a guideline for code review.  To write readable code/ clean code,  practice the code review based on guidelines. 

Also, really work on coding skills, read a lot of code. For example, HackerRank, Two string, hundreds of solutions - compared the difference, find the best one. And be the best one in your coding practice. 


HackerRank: Two string - thinking in JavaScript over 10 ways


http://juliachencoding.blogspot.ca/2016/03/hackerrank-two-string-thinking-in.html

Thinking in C++ over 15 ways
http://juliachencoding.blogspot.ca/2016/03/hackerrank-two-string-thinking-in-c.html

6.
http://matt-welsh.blogspot.ca/2010/06/working-for-google.html

7.
http://matt-welsh.blogspot.ca/2016/06/death-by-peer-review.html

Very good analysis - peer review - anonymous/ ad hoc  vs principled leadership organization

Which is more controllable? Work on controllable things - NO Matter how hard it is, you work hard, you will make it one day.





Good programmer or just good Googler - a small research

June 14, 2016

  Julia knows that it makes difference if she knows APIs very well. It helps her to communicate and also problem solving on algorithm problems. So, she starts to try idea - use memorization to help coding. Memorize Array/ Double Linked List/ Stack/ Queue/ String/ Hashtable class in C#, C++, Java, JavaScript, and then, prepare more coding in the future. She likes to read more C++/ Java/ Java Script code. 

  Get organized. Get more prepared by more reading as a software programmer. Practice Leetcode algorithms/ practice on HackerRank, also, reading APIs, and then memorize APIs like bible verse memorization,  is a good practice.   

 Good programmer or just good Googler
20 minutes research about good programmer or just good Googler?
http://www.hanselman.com/blog/AmIReallyADeveloperOrJustAGoodGoogler.aspx

http://getinvolved.hanselman.com/

http://www.hanselman.com/blog/ImAPhonyAreYou.aspx

http://codekata.pragprog.com/

https://www.quora.com/Do-developers-memorize-all-tags-classes-and-functions

http://app.pluralsight.com/courses/hanselman-speaking

                       Memorization brings up a lot of learning process
1. Where to find documents?
2. Learn the design, improve reading, learn something new, or the API document easy to understand?
3. Start to work on simple examples.
4. Know the difference to get prepared early.
    Know how to make difference to get prepared early. 
5. Preparation takes time to learn. 

Sunday, June 12, 2016

Double Linked List - C++, C#, Java, JavaScript

June 12, 2016

Motivation behind memorization APIs as a programmer:

                      Good programmer or just good Googler
20 minutes research about good programmer or just good Googler?
http://www.hanselman.com/blog/AmIReallyADeveloperOrJustAGoodGoogler.aspx

http://getinvolved.hanselman.com/

http://www.hanselman.com/blog/ImAPhonyAreYou.aspx

http://codekata.pragprog.com/

https://www.quora.com/Do-developers-memorize-all-tags-classes-and-functions

http://app.pluralsight.com/courses/hanselman-speaking

                       Memorization brings up a lot of learning process
1. Where to find documents?
2. How to design, understandable?
3. Start to work on simple examples.
4. To get prepared early. It makes difference.

Work on Double Linked List class/ interface - go over all APIs of 4 languages -> Memorize -> Compare, ask questions -> start to prepare to use them in the future projects.

C#:
LinkedList class
https://msdn.microsoft.com/en-us/library/he2s3bh7(v=vs.110).aspx

Properties:

Count,
First,
Last

25 Methods:

AddAfter(LinkedListNode<T>, T)
AddAfter(LinkedListNode<T>, ListListNode<T>)

AddBefore(LinkedListNode<T>, T)
AddBefore(LinkedListNode<T>, ListListNode<T>)

AddFirst(LinkedListNode<T>, T)
AddFirst(LinkedListNode<T>, ListListNode<T>)

AddLast(LinkedListNode<T>, T)
AddLast(LinkedListNode<T>, ListListNode<T>)


Clear()
Contains(T)
CopyTo(T[], int32)

Equals(Object)

Finalize()
Find(T)       - Find the first node that conains the specified value
FindLast(T)   - Find the last  node that contains the specified value

GetEnumerator()
GetHashCode()
GetObjectData()
GetType()

MemberwiseClone()
OnDeserialization(Object)
Remove(T)
Remove(LinkedListNode<T>)

RemoveFirst()
RemoveLast()

Statistics:

June 12, 2016 10 minutes

More reading:
http://matt-welsh.blogspot.ca/2014/01/getting-job-at-google-for-phd-students.html

http://matt-welsh.blogspot.ca/2010/11/why-im-leaving-harvard.html

http://matt-welsh.blogspot.ca/2010/05/secret-lives-of-professors.html




Queue Class - C++, C#, Java, JavaScript

June 12, 2016


Start to spend time to go over all API for those 4 languages.

1. C++:

2. C#: 

3. Java:
1. PriorityQueue
https://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html

2. Queue
https://docs.oracle.com/javase/7/docs/api/java/util/Queue.html

4. JavaScript

Will come back.

Stack Class - C++, C#, Java, JavaScript

June 12, 2016

Start to spend time to go over all API for those 4 languages.

Will come back.

Hashtable - C++, C#, Java, JavaScript

June 12, 2016

Start to read all Hashtable class API, read code and start to memorize all of them. Invest time on them, 30 minutes a time.

C#:
Dictionary class
https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx

Interface implemented:
IDictionary,
ICollection,
IEnumerable,
IReadOnlyDictionary
ISerializable
IDeserializationCallback

Properties:
Comparer,
Count,
Item[TKey]
Keys
Values

Methods:   15 methods

Add(TKey, TValue)
Clear()
ContainsKey(TKey)
ContainsValue(TValue)
Equals(Object)

Finalize()
GetEnumerator()
GetHashCode()

Extension Methods:
https://msdn.microsoft.com/en-CA/library/bb383977.aspx






C++:

Java:

JavaScript:


Statistics:
1. June 12, 2016 30 minutes