Wednesday, November 15, 2017

Order string (VI)

Nov. 15, 2017


Algorithm Study and Code Review


Here is the code related to the algorithm. I like to write a blog on the code. The main idea is to use primitive type string, just add index to the first element of string array, avoid a struct or a class definition. Kind of tricky. 


Follow up study 

Nov. 16, 2017

It is always a good idea to search code review to read IComparable<T> code review. I sepnt over 20 minutes to read the algorithm: Dynamically sorting with IComparer. And one of statement in the code review reads like the following:

This
public int CompareTo(ProductSortAttribute other)
{
    if (this.Index == other.Index)
    {
         return 0;
    }

    if (this.Index > other.Index)
    {
         return 1;
    }

    return -1;
}
can be shortened to
public int CompareTo(ProductSortAttribute other) {
    return this.Index.CompareTo(other.Index);
}
Since Int32 also implements Comparable<T>.

What is Int32?



Here are a list of things Julia starts to her independent study:
1. What is Int32? A structure
2. What interfaces does Int32 implements? IComparable<T>, IFormattable, IConvertible.
3. Where is the source code of Int32 in mscorlib? Link is here.

Comparable <T>  study



Sometimes, it is so easy to find an excellent lecture notes, and then I can follow quickly how to write basic comparer. Here is the one.

Order strings (V)

Nov. 4, 2017

Introduction

It is fun to continue to work on C# practice on this algorithm called order strings.

I reviewed the code and made some change, C# code is here for me to review later.

Tuesday, November 14, 2017

Order string (IV)

Nov. 14, 2017


Introduction


It is my favorite C# code to study, through the code, I can tell that the player has more C# coding experience compared to me, and also the trick used to do numeric comparison to make code so simple and only take one line of code, referring to line 44.

I just could not believe that the experience the player has and it makes coding so enjoyable experience, like a competing sports.

I could not express more enjoyment to read other people's code. When I read those excellent engineering idea, creative idea to solve the problem, I cannot believe that it makes coding such a challenging sports and I am just glad to be a follower.

Code study


I reviewed the code and rewrite the code, here is the code. I have to push myself to get LINQ to my daily coding practice, so I am ready one day to write a web application with much better code using LINQ.


Relax your mind 


I like to use this video to relate to read an excellent engineering idea to deal with solving problem.


Order string (III)

Nov. 14, 2017


Introduction


It is the best time to learn C# programming using one of medium algorithm in the Morgan Stanley codesprint. The design of algorithm includes using BigInteger class and also LINQ OrderBy and OrderByDescending.


Code study

I reviewed the code first, and then I rewrite the code. C# code is here.

Order strings (II)

Nov. 14, 2017

Introduction


It is time for me to learn how to write a C# program and also review other's code. The second study code is written using SortedDictionary. DescendingComparer class and DescendingComparerI class are defined.


Code design talk 


Here is the C# code after I review the code.


Order strings (I)

Nov. 14, 2017

Introduction


It is the time for me to study code submission using C#. This is the first C# code submission I studied, delegate is the keyword used in code, and also string.TrimStart.

Here is the C# code after I reviewed the code.


Code design talk 


The structure is used and called OrderString.

structure  OrderString
{
    public int      Index;
    public string Lexicographic;
}



Monday, November 13, 2017

Pluralsight.com - becoming an outlier

Nov. 13, 2017

Introduction


It is such a great privilege that I got subscription of pluralsight.com monthly. It is time for me to review how many hours I spend on pluralsight.com last 12 months.

I like to revisit the course called becoming an outlier: reprogramming the developer mind by cory house.

Course study


Plan to take some notes and do some research from lecture notes.






Do it yourself - Auto maintenance work

Nov. 13, 2017

Introduction


Once a while, I find myself in the trouble to keep up with knowledge of automobile, so I have to learn a few things through youtube.com. For example, how to install a car battery? I did once recently. This past October, how to put a backup tire, that was my favorite research through youtube.com, I got a flat tire and then I like to do some research how to fix the issue by myself.

My research is so shallow this October, I watched 2 or 3 videos to put a backup tire, and then I tried to do it myself, I could not take off lock nut off no matter how hard I tried. So I went back to watch videos, until a few hours later, one of videos shows that it is to use your feet to leverage the power. I used the tip and solved the problem puzzled me more than 2 hours.

Learning is fun


I sent my car to Canadian tire auto repair last Monday for 4 pm appointment, and I was told that the tire cannot be repaired, so two new tires will cost more than $300 dollars. I politely declined the advice, and waited last Saturday and then drove to O Tire, and I got the tire repaired. There are two nails in the tire, the cost of repair is $60 dollars, with life time warranty.

I spent 10 minutes to touch all tires's tooth in O Tire store and try to understand the technology of tire.

My low beam light


One of my weakness is to be patient and be able to solve real problem in my daily life, walk away with things like wechat talks, reading or sharing. I need to take care of a lot of things, like maintaining good friendship with Christian friends, sometimes it means a long lunch together with group of people.

I checked tonight that two of low beam light bulbs stop working. I found that low beam light has some issue, but until today in the dark outside of the home, I did make sure that light bulbs do not work.


To be outlier



It is time to review the course I learn from pluralsight.com called "Become an Outlier: Reprogramming the Developer Mind", I did in July 28, 2017. I plan to revisit the course again and try to apply the learning to my daily life.



Sunday, November 12, 2017

count pairs

Nov. 12, 2017

Plan to study the hard level algorithm called count pairs, the problem statement is here.

Moving Elevator

Nov. 12, 2017

Plan to study 30 minutes a time on this hard level algorithm called Moving Elevator. The problem statement is here.

Check the leaderboard and also find a googler with code submission, the linkin profile is here.




How to convert finite automata to regular expressions?

Nov. 12, 2017

Plan to study the stackoverflow question How to convert finite automata to regular expressions?


Stock porfolio - Morgan Stanley campus codeathon 2017

Nov. 12, 2017

Introduction


It is such a great contest for me to play last weekend. I was pushing myself to get back to play coding contest and then train myself to work on hard level algorithm. The first two medium level algorithms in the contest are so helpful for me to catch up learning on C# programming and also warm up the statistics. As a software programmer, I learn that the contest does not require me to write very complicate code, I need to stay cool and also think about the foundation of statistics sometimes, need to refresh my knowledge and quickly look up.

Algorithm study 


Plan to work on the hard level algorithm called stock portfolio, Morgan Stanley campus codeathon 2017.

The problem statement is here.

It is also a hard level algorithm, my favorite algorithm to learn and apply some dynamic programming techniques.


Miss my mother and she will be remembered

Nov. 12, 2017

Introduction


It is the the first Sunday I will live without a mom in the world. She passed away on Nov. 11, 2017 at the age of 86.

My mom was such a great person who had lived her life to the full. I have so much good memory to spend time with her. Specially after I went to college, she still corrected me when I made mistakes, and she answered my phone calls when I felt lonely a lot of years, and we lived together back in Florida together back 4 months in 2000 and 5 months in 2001.

I will go to Willingdon church this morning, and I like to pray and wish everything is great with all I have.

God blesses us, have a wonderful Sunday.

Nov. 25, 2000
Julia with her mom qingfu liu in Orlando, Florida, Seaworld theme park. At that time, my mom turned 70 years old. I was in my early age to experience the life in USA.



January 26, 2012

Julia and her mom spent time at the beach of the city of Shenzhen.




Julia walked on beach with her mom in 2012. The video link is here on facebook.


2014 Chinese spring festival

Julia interviewed her mom how to celebrate China new year. Here is the link on youtube.com.

Julia took care of mom while she played tennis and had some conversation with her mom. Here is the link on youtube.com.


Oct. 13, 2017, 3 PM, first time in my life, I washed my mom's feet with the help of 3 other sisters.


Bible teaching is very good about washing each other's feet. I shared my learning with my sisters, and they all liked the idea and helped me to wash my mom's feet first time.

Quora study: Shriram Krishnamurthi

Nov. 12, 2017

Plan to study a computer professor and how he thinks in terms of education, computer science, quora platform, and other things.

The quora profile is here.


Saturday, November 11, 2017

Order strings

Nov. 11, 2017


Introduction


It is the first medium algorithm in Morgan Stanley Campus Codeathon 2017. I spent a few hours to work on the code. Now it is 11:54 PM. I am trying to get more points. What should I do to get more points?

The problem statement is here.


I am very patient to read problem statement again and again, try to find the clue what is missing in my problem solving. Look at those test cases:


Follow up after the contest

Nov. 12, 2017 9:43 pm
Julia tried a few submissions. Here are the link to her C# submissions.

First submission, only score 8 out of 40. Here is the C# code of first submission.
Second submission, only score 5 out of 40. Here is the C# code of second submission. Change numeric type from int to long, score from 8 lower to 5.33
Third submission, numeric type, consider the length of string 50, check one char a time. Score goes up from 8 to 23 out of 40. 
Fourth submission, C# code is here. 

Plan to study all C# submissions.


The great game of Galia

Nov. 11, 2017

Introduction


It is the first medium algorithm of Morgan Stanley Campus Codeathon 2017. Now it is 7:38 PM, Saturday evening. I like to spend some time to work on the first medium algorithm.

I like to make this algorithm as simple as possible. Let the fun begin.

Now it is Nov. 12, 2017. It is 12:22 Am. I fully understand the problem statement, and also I like to code something for my contest.

Since the contest will end in Sunday morning 10:00 am, I am better to go to sleep and get up early at 6:00 AM to work on the contest. Now it is 12:47 AM, better to sleep on this algorithm.

Next step 


I woke up 6:30 AM, but I enjoyed the long stay on the bed with music and wechat reading. Now it is 9:32 AM. The contest will end in an hour. I need to work on something.

Read quickly on the algorithm leaf node count on binary search tree. The link is here.

These are steps:
1. Find all sequences
2. Construct binary search tree
3. Count leaf node
4. Add to the sum
5. Evaluate the algorithm time complexity and space complexity
6. Try to optimize

There is timeout issue. So I have to use dynamic programming, using combinatorics, and build a recurrence formula. So the code should be very easy.

Now it is 9:56 AM, the contest is extended to 10:30 AM.

I like to show my worksheet, and it is my way to push myself to work hard on algorithm, no matter how hard it is.






Friday, November 10, 2017

Eight years is like a blink of eye

Nov. 10, 2017

Introduction


It is like the blink of eye that I have spent almost 8 years in the city of Vancouver starting from April 18, 2010. I still remembered the conversation, plans my friend prepared for the 14 days road trip from April 1 from Florida to Vancouver, in the year of 2010.

I like to celebrate my hard working eight years!

Plan to write an answer on quora.com how I planned the trip with a friend over 14 days.


Thursday, November 9, 2017

What is the third algorithm to ask code review?

Nov. 9, 2017

Introduction



It was 11:10 pm, and I spent over 30 minutes to go over the algorithm I practiced, and try to find a good one to ask code review.

Now it is 11:45 pm. The one I am reading now is leetcode 212 using trie data structure, the blog is here.

I came back from a break this September and asked two algorithms based on my mock interview practice. Today I like to find the third algorithm to ask code review.


Algorithm review

Trie 


It is also good warm up to review my favorite practice and share with the community.

Plan to study the algorithms of Trie from code review website, Trie implementation for left to right wildcard search, and another one: Trie (tree form) in Java

4 Sum



It is Harvest Time! (1 Corinthians 3: 5 - 9) (I)

Nov. 9, 2017

Introduction


It is time to review what I have completed on mock interview, I have completed almost 4 rounds of mock interview. I like to review what I learn, and show some analysis what I did good or wrong.

Let me first to give a topic for my blog, I google using keyword it is harvest time. Here is the preach I like to go over and see if I can write similar blog to document my learning. Here is the preach link, It is Harvest Time! (1 Corinthians 3: 5 - 9).

It is Harvest Time!


There are four stages to get to the harvest, prepare the soil first, sow the seed, cultivate the soil and reap the harvest.

I spend 10 - 20 minutes to go over those 28 interviews, and I read the comments for each interview. And I just enjoy the work I have completed. No matter I stumble on the algorithm or fail to help the peer, I go through the learning process.

My best teacher to help me write this series is this Moody bible institute professor, who writes very well on this article. Pastor Keith Krell is here.

Performance


This is the first time I finished over 28 mock interviews, and I remembered the worst performance to solve a Sudoku algorithm, I got rate 1 out of 7 for coding on April 11. After six month, I posted the question on code review on the algorithm on Nov. 6, 2017, here is the link called "Sudoku solver with clear structure". 


Reference


1. First round mock interviews, 27 interviews.

 





C# Array class document reading

Nov. 9, 2017

Introduction


It is best investment of time to read C# Array class documentation. What I do is to print out a copy and hold the copy to read again and again, ask questions, take notes, and write down what I learn.

Here is C# Array class, I do not have chance to go over the object-oriented design course, but I like to ask myself to memorize all APIs, and also be able to clear all the terms shown in the document.

As a programmer, I like to write code quickly using existing API of Array class, and be able to understand those interfaces as well. I find out that I am interested in the discussion on stackoverflow on those C# interface, and I try to figure out what the difference is.

Read like bible 


I like to read C# Array class like bible. I will mark those words showing in the document, and then I will use those words when I need to write blogs about the algorithm.

C# Array abstract class source code scout

Nov. 9, 2017

Introduction


It is the first time I read C# class Array's source code through Microsoft website. I spent a few hours t o read over 3000 lines of code. I call it scout since I have written a few blogs about C# Array but it is the first time I have chance to read C# code.

Take notes, please!


It is so interesting for me to read C# Array class, so I have to be able to understand why it implements five interfaces and it is an abstract class. I am very curious about how the code is structured in one class over 3000 lines of code.

Read C# Array source code here. I found the link in the first few paragraphs of Array document.

Read C# SorterObjectArray - mscor.lib, the link is here.

Plan to write down some notes to help myself to continue to get educated on C# Array, and understand the design of .NET framework. 


Leetcode 151: reverse words in a string

Nov. 9, 2017

Introduction


It is in-place to make the algorithm a classical algorithm for any language. I have practiced over a few times last 6 month, and on Nov. 8 10 PM I had chance to write the algorithm in 30 minutes, and the code passed all test cases.

Usually first few time I have to figure out the issues I have and then found ways to solve the algorithm. Last night practice is no longer challenge for me anymore, I noticed that and started to look into Leetcode 151 discussion panel after mock interview.

Algorithm study


Here is the C# practice.


Quora read: Thanh Trung Nguyen

Nov. 9, 2017

Plan to read Thanh Trung Nguyen, the profile is here.

Wednesday, November 8, 2017

Quora read: Lalit Kundu

Nov. 8, 2017

Plan to read the answers from Lalit Kundu, here is the quora's profile.

My favorite question is about implementation skills. The answer is here.

Leetcode 10: regular expression - Fun to play

Nov. 8, 2017


Introduction



It is really fun to play with code related to recursion tree after the mock interview. I ran into various error with a simple test case each time using Leetcode online judge, I learn from each failure and try to play with them. It is fun to play over hours and actually I like to learn something here. Let me document the issues first, and then figure out the solution later.

Test cases to help 


I like to list the test cases to help design the algorithm.

"", "a*"
"", "a*b*"
"bbbba",".*a*a"

Here is the C# code with a bug timeout - need to run at least 1 time first for a* pattern, and then run 0 time for a * pattern.


The test case for time out is here:
"aaaaaaaaaaaaab"
"a*a*a*a*a*a*a*a*a*a*c"

And the code causes the problem is shown in the following picture:

Here is the C# code with fix of timeout:


Catalan number

Nov. 8, 2017

I will write something here about the algorithm. Will come back very soon.

Transcript is here. I will write down the story later on.



Follow up 


January 17, 2018

It is the advantage of mock interview. I learned the algorithm after I had practive over a few times. But some one with very good talent on algorithm just showed me his way to solve the problem.

The peer just wrote down a 5 x 5 matrix using x to reprent each number, and then he went over the first row, to start from the first row from left to right, write down one for each column; and then go to next row, and then quickly from left to right, add the value underneath and left neighbor in the same row. He finished the process in less than 5 minutes, and then showed me the calculation of value for n = 4.

It is the best coaching experience for me. I learn that some one is much better than me to understand the algorithm. And after mock interview, the peer told me that he got some training in competitive programming before.

Tuesday, November 7, 2017

Leetcode 10: regular expression

Nov. 7, 2017

Introduction



It is such an adventure to work on Leetcode 10: regular expression. I chose the algorithm as my most favorite mock interview algorithm on quora.com last month, the link is here. But of course I was so nervous since I could not believe what I will write down.

My practice 


The peer was very nice and also helpful. I went over each test case and explained the matching, and I told the peer that I will use one of test cases to do whiteboard testing, recursive tree I will use at least 2 branch. For any char followed with *, I will match 0 time or 1 time or more than 1 time.

Here is my C# practice code. I ran the test cases, the code failed the test case with "" and pattern "a*". So I tried to fix it, added one base case, but still failed the test case. The code is here.

I told the peer that I will fix it after mock interview. I already took 43 minutes. Such a great workout.


Discussion between two peers 


Here is the discussion between two peers in mock interview:

how do you match "abb" with pattern "b*b"? Peer asked, and he put down the test case next to line 68.

I think that there are 3 branches in recursion tree:

b* match 0 time, so "abb" will check to match "b", return false;
b* match 1 time, so  'a' != 'b', return false;
more than 1 time will also return fail.

Let us check "bbb" with pattern "b*b", Julia suggested to work on.

We like to check 0 time, 1 time or more than 1 time.

For 0 time case, "bbb" will try to match "b" since "b*" 0 time means empty string. Return false;
For 1 time case, b matches b*, so "bb" will try to match "b", return false;
For more than 1 time case, "bb" will match "b*b", go back to 3 cases, return true.

Show some image to help understand the discussion:


Feedback from the peer



I just could not believe that the peer was a competitive programmer in high school, and then he just finished his computer science graduate school two months ago. He showed to me how strong his analysis was to handle the algorithm and coding was fast and quick later on, he finished in 12 minutes and it seemed to me that he got very good training on the algorithm. Will continue on my next blog Catalan number on the performance. The peer played contest on csacademy.com.


Follow up 


Nov. 8, 2017
The code is updated with code from line 37 to line 41 to fix the base case, empty string "" matchs "a*" pattern string.

C# code is here.


Two peers comparison


It is interesting to know that two peers can evaluate each other with top rating, but how about to compare the profile of two peers and see what we can tell from those numbers.


Divide to n small linked list with length difference at most one

Nov. 7, 2017

Introduction


It is the first time I went through a friend met in mock interview, we both worked on the same algorithm together. I wrote two version of code, one is recursive function, one is iterative one.

Problem statement can be written in the following:

Given a Linked list, split it into x number of smaller linked list where the size difference between any two list should be at most 1


Algorithm practice


It is so interesting to have discussion with the peer outside mock interview platform. I always think like a math major graduate student, the first 5 minutes I will go over anything including mathematics, and then I rested all time. Since I went through the linked list practice in 2016, here is one of linked list practice blog to document my practice. 

I like to observe how the peer picked up the analysis and worked hard on the coding. For me, it is just another routine and I do not need to think about too much. 

C# code is written here, and later on I will compile and add some test cases. 

First, I wrote a recursive solution. The link is here. And then I wrote an iterative solution, the link is here. 

Also, I like to give the code review for the peer's code. The code is here. 


Statistics


Time spent in discussion 7:15 pm - 9:18 pm 



Code review daily read

Nov. 7, 2017

Introduction


Usually there are over 40 algorithm asked in code review, but only less than 10 algorithm will be posted on twitter.com. So I just need to follow the code review twitter account and then I can follow the algorithms every day. Here is the twitter link.

On Nov. 6, 2017, there is a twitter post related to the algorithm I asked. Here is the question:
Sudoku solver recursive solution with clear structure.

Monday, November 6, 2017

Special case of Leetcode 230: Kth Smallest Element in a BST

Nov. 6, 2017

Introduction

It is the hard level algorithm called Kth smallest element in BST. When k value is one, the problem can be called to find largest smaller element in a binary search tree given the number.

It is very good discussion with the peer how to write an iterative solution. I did write down the code using C# and then I have to figure out how to get good rating from the peer.

Here is the C# practice code. I added main function after the mock interview.

Code review 


Here is the evaluation I got. I need to learn how to work with the peer, and follow the hint better.



Follow up 


Nov. 7, 2017
I found a bug in my code, the null pointer exception on line 35:
while(currentNode.right.key < num)


Here is the fix, C# code is here. currentNode.right == null is added to line 41. ( * bug fix No. 1*)

Nov. 10, 2017 11:44 PM

I finally figured out the thing I did wrong in my last mock interview. The code I wrote in Nov. 6 is wrong, and also the fix of bug on Nov. 7 ( * bug fix No. 1*) is also wrong. I finally understood that I was too stubborn and did not take the advice in mock interview.


Also the above code will not work for the following binary search tree:
Given the value 11, largest smaller BST key's value should be 10, but the solution will return 8 instead. Also the above code has null pointer run time exception on line 36, currentNode's right child may be null pointer, need to put a guard clause to check currentNode.right != null.


Nov. 10, 2017
11:19 PM
I had 10:00 pm mock interview, the peer worked on the algorithm. I had chance to find my problem based on the following test case. Great thanks for the peer, who is very patient, and think about the test case carefully.

Given number 11, the largest smaller BST key is 10. How to find node with value 10?   
First, start from root node with value 19, 19 is bigger than 10, so go to its left child. Left child value is 8 and it is smaller than 11, then set the value to look for (denote as LargestValue) as 8. And go to its right child to search. The node's value is 11 which is not smaller than 11, then go to left child 10, and set LargestValue = 10. Node 10 is leaf node without any child. 10 is the answer. 

In other words, find smaller one, go right; find bigger one, then go left. Until the traverse reaches the leaf node. Left, right, left. 

Learning Interface through C# 2000 things

Nov. 6, 2017

Introduction


I got some advice to code to interface through the code review, so I plan to spend 2 hours to go over all interface things through C# 2000 things.

Here is the snapshot:


Code to Interface


It is so interesting to know that I enjoy to go over interface learning through C# 2000 things first. In order to understand the C# array and also IEnumerable interface, I need to go over the basics of C# first.


Actionable Items


Study Abstract class Array

Nov. 7, 2017


Actionable Item

Work on C# Array abstract class study

How many interfaces are derived from?

IClonable
IList
ICollection
IEnumerable
IStructuralComparable
IStructuralEquatable


Properties


IsFixedSize
IsReadOnly
IsSynchronize
Length
LongLength
Rank
SyncRoot

Method ( 10 methods a time)

AsReadOnly<T> (T[])
BinarySearch(Array, Int32, Int32, Object)  Use IComparable interface implemented by each element of the array and by the specified value.
BinarySearch(Array, Int32, Int32, Object, IComparer) Search a range of elements in a one-dimensional sorted array for a value, using the specified IComparer interface.
BinarySearch<T> (T[], T)
BinarySearch<T>(T[], T, IComparer<T>) Searches an entire one-dimensional sorted array for a value using the specified IComparer<T> generic interface.

BinarySearch<T>(T[], Int32, Int32, T) Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable<T> generic interface implemented by each element of the Array and by the specified value.

BinarySearch<T>(T[], Int32, Int32, T, IComparer<T>) Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer<T> generic interface.

Clear(Array, Int32, Int32) Sets a range of elements in an array to the default value of each element type.

Clone()
ConstrainedCopy(Array, Int32, Array, Int32, Int32) Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. Guarantees that all changes are undone if the copy does not succeed completely.

Start to read a question:
Why array implements IList?

IEnumerable vs IList

Nov. 8, 2017

What problem does IStructuralEquatable and IStructuralComparable solve?

Nov. 9, 2017
Read C# Array source code here. I found the link in the first few paragraphs of Array document.

Read C# SorterObjectArray - mscor.lib, the link is here. 

Code Review: Sudoku solver recursive solution with clear structure

Nov. 6, 2017

Introduction


It only takes less than one hour to post the question on code review. The algorithm is Leetcode 37: Sudoku solver, the most classical depth first search algorithm. My practice is documented here.

It is a wise decision to ask a question on code review website, this time I learn a few things from code review.


Code Review


Code review link is here.

I got very good review. My most favorite advice is Code to interface. Use IEnumrable<char> instead of using HashSet<char>.

Sunday, November 5, 2017

Shen Neil - Shanghai Jiaotong university alumni

Nov. 5, 2017

Introduction


It is so interesting to be an alumni of Shanghai Jiaotong University, China. I went back to have a vacation this October, I had to meet classmates of undergraduate 70141 and also graduate class 8902.

My undergraduate class is named as 70141, and my graduate class is names as 8902.  I had chance to meet some of my classmates and I had chance to follow more on wechat about their stories. One of 8902 classmate posted the blog about Shen Neil who is my undergraduate classmate of 70141, of course, he is no longer the first degree of my friend circle. My close friend's circle is engineers and teachers of alumni of 70141 and 8902 classes.

Here is the article written in Chinese for me to study in 20 minutes tonight. Chinese sentences are written like this: Four year Shen Neil makes 2 billion dollars, but he invested 50 billion first, in 11 years make 2600 billion dollars.

" 投资教父"沈南鹏,4年赚到20亿还嫌不过瘾,他一举砸下500亿 , 11年创下2.6万亿奇迹!

Study of Shen Neil 


Shen Neil's wiki page is here. 
Shen Neil's wiki page in Chinese is here. 

His partner of Sequoia: Michael Moritz


52 minutes interview called Sequoia's Neil Shen to Entrepreneurs: "Follow Your Heart", the video link is here published by Stanford Graduate School of Business.

Several arguments to look into from the article:

Arguments:

不过天才就是天才,在十几次面试的过程中,沈南鹏就摸到了门道。

此后不到两个星期,他就把江恩理论、5个波浪循环、MBS、CDO、中国国债、布伦特原油报价等问题搞透了。

Facts:

就在另外两个人绞尽脑汁在纸上比划的时候,沈南鹏不到5分钟已经给出了答案。

原来不太懂中国的商业环境,到了1999年,我已经比较‘土鳖’了

Saturday, November 4, 2017

Leetcode 611: Valid Triangle Number

Nov. 4, 2017

Introduction


It is the medium level algorithm. The algorithm is very challenging to lower the time complexity from O(n3) to O(n2) using two pointer techniques or binary search. The peer gave me the hint to lower the time complexity, and then I started to think about binary search with time complexity O(n2logn), and then the peer gave me hint to continue to optimize the time complexity.

Plan to write C# code and also read discussions for the algorithm in short future.




TED Talks: 'Grit: The power of passion and perseverance'

Nov. 4, 2017

Watch 6 minutes video, a TED talk: Grit: The power of passion and perseverance. The article with video link is here.


Plan and budget

Nov. 4, 2017


Introduction


I like to write something about project management and cost analysis, and share my story about my October vacation.

I came back from the vacation on Oct. 20, 2017, recovered from the jet lag, and started to catch up the projects at  work. And I like to document how I learn to plan and how to budget, and understand how I can make things better.

It is time to talk about money, and I believe that a very smart programmer should have learned so many things through years, and I just make you laugh when I share my learning and how I understand the money talk.

Money talk 


Will come back very soon.



Galaxy S6 - Tips, Tricks & Hidden Features

Nov. 4, 2017


Introduction


It is two months to be a user of Samsung Galaxy S6 mobile phone. I enjoy so many things last two months and really like to write an eulogy for my new companion - a refurbished Samsung S6 phone.

As a mobile phone user, I need to keep learning the mobile apps and keep update specially weekends.


Study of the video 


I always said those sentences in my vacation to my sisters, "I do not need a brand new iPhone or latest version Huawei phone,  or a brand new luxury car to help my confidence. I am a consumer and then I tell you what I like to use, a used one."

My point is that it is not too difficult to purchase a brand new phone, I can spend extra $200 or more to get a brand new Samsung S6 this August. It takes so much time to catch up the advanced features for the phone. As a website developer, I also have to educate myself as a product manager for the website, I need to learn how others are expecting to use the mobile phone first, and then estimate how much computing power I can generate and produce a decent mobile website.

12 minutes video is here called Galaxy S6 - tips, tricks & hidden features.

17 minutes video is here called 10 Hidden Features of the Samsung Galaxy S6 You Don't Know About.

Actionable Items


Follow up
Oct. 13, 2019
I found out that I did not learn the basics of investment. I found out that in 2018 I had over $50,000 Canadian dollars with Scotia bank, I earned less than $10.00 dollar interest in 2018.

I also reviewed my US dollar account with Scotia bank from 2010 to 2017, but I did not have any interest. I found out that I wasted so much opportunity, since I missed 10 year bull market from 2010 to 2018.

Leetcode 41: First missing positive (II)

Nov. 4, 2017

Introduction


It is so pleasant to meet a peer through mock interview, and watch and learn how the peer solves the algorithm with a few of hints, write optimal solution to pass all test cases. Through 40 minutes interview, I also had chance to review the code, shared my experience of coding style, how to apply to the peer's code.

It is so exciting to see how I can learn to share my experience just in-time, and help a young programmer to pay attention to coding style. One thing I liked most in mock interview is to show the peer how to break giant expression, what to iterate in the while loop.

Also the peer chose to use C programming language, so I know that she must be a top-talented person, because those machine learning algorithm matches me to top talent in the world this Saturday morning. Only few of us can choose to use C to do interview these days. Through mock interview, I experienced C programming and do not pay attention too much since I need to refresh my C programming knowledge.

Algorithm Talk 




Leetcode 18: 4 Sum

Nov. 4, 2017

Introduction


It is such a great mock interview this morning starting from 10:00 am. I had to work on the algorithm Leetcode 18: 4 sum in the time limit of 35 minutes. I did a few things to make the mock interview great learning experience. I wrote an algorithm, passed the compiling and then passed all test cases without any bug. The algorithm has optimal time complexity although extra space is needed.

Here are highlights:

 1. I chose the algorithm using time complexity O(n2). Two sum pairs are saved to the dictionary for lookup later on.

 2. Whiteboard testing was very helpful, I chose the easy one [3, 2, 1, 4, 5] and the given 4 sum is 12 = 1 + 2 + 4 + 5. Compared to the test case given in the problem statement, this one is easy to follow.

3. Through whiteboard testing, I found a bug in my design. The array may have duplicate numbers, and then I spent extra 5 minutes to change the design, in line 78, I added two extra elements in the array to save index number of the array.
newList.Add(new int[]{no1, no2, i, j})

4. Through the whiteboard testing, I modified the code to make it more easy to follow. I added var no1, no2, no3, no4, assuming that no1 <= no2 <= no3 <= no4, and the index of four numbers in sorted array is in ascending order.

5. I spent less than 3 minutes to fix all compiling errors.

6. The code runs and pass all test cases without any bug.

Code review


The code I wrote in mock interivew in C# is here to view.

Based on my last practice on Leetcode 18: 4 sum in August 2017, I worked on the feedback. I need to write a run-through code, I have to simplify the solution in order to fit in 30 - 35 minutes.

A few things I did are very helpful to expedite the process this time. The most simple test case is chosen to do whiteboard testing; the whiteboard testing is not a fake one, in the process of testing, I found a bug first, and then came out the fix, and in-between I added a few more variables to make code more easy to follow, avoid bugs.

Feedback from the peer


The peer did not choose to use the video, but her knowledge of algorithm is very helpful. I did have chance to learn the algorithm compared to two pointers techniques.



Friday, November 3, 2017

Leetcode 37: Sudoku solver

Nov. 2, 2017

Introduction


It is the time again to write a Sudoku solver. Here is my C# practice, the peer told me that I do not need to run the code using web browser compiler.

The mock interview was supposed to end in one hour to 11:00 PM, but it actually ended at 11:50 PM. I spent more time to chat with the peer until the session terminated due to timeout.

After that, I started to run the code, first I fixed the grammar error line 62. The Split function of string will have an array of string, not an array of char. The line 62 has compile error. It is the easy and quick fix. But I came cross the index out of range run time error. This one I could not pinpoint the error.

I was troubled and tried to set up test case until 1:00 AM, and then I called it a day. I did not do whiteboard testing, instead I tried to guess what is possible places to go wrong for index-out-of range error. With whiteboard testing, it should be a quick fix. But without it, I wasted almost one hour but I still could not find the issue until 1:00 AM.

Whiteboard testing


The whiteboard testing is to use a test case and go over the code line by line, write down the value for each variable, and run the code virtually with results.

If I do whiteboard testing, I should have found the bug on line 91. Here is line 91 with the bug:

for(int row = startRow; row < row + 3; row++)

actually when I run the whiteboard testing, startRow = 0, then row is from 0 to 2. The statement should be written in the following:

for(int row = startRow; row < startRow + 3; row++)


Nothing beats whiteboard testing 


In terms of bug fixing, nothing beats whiteboard testing. Go over a simple test case, go over each line of code, put the result next to the code.

Actionable Item


C# code is updated and it passes all test cases after mock interview. The C# code is here. 

Review sudoku algorithm on code review website, and I studied the question:

Solving Sudoku using backtracking

Plan to write C# code based on the above code review. I feel that there are a few things I can apply to my mock practice code. 


Plan to write a blog to review algorithm of longest common subsequence written in Chinese. The link is here.

Leetcode 41: First missing positive

Nov. 1, 2017

Plan to look into Leetcode and find the similar algorithm called get smallest nonnegative number.

Get smallest nonnegative number, do not change the array.

My C# practice code is here on Nov. 1, 2017

Also, I spent almost 50 minutes to interview the peer on Nov. 2, 2017 and had some discussion about the algorithm. I like the peer to go over the base cases to show very good reasoning.

[],   0
[0], 1
[1], 0
[0, 2, 3]  1
[3, 0 , 2] 1
[0, 1, 2, 10000]


Leetcode 41: First missing positive 


It is the hard level algorithm. Time complexity is O(n), space is O(1).