Thursday, December 21, 2017

How to find time to work on coding challenges?

Dec. 21, 2017


Introduction


I had a mock interview on Dec. 20, 2017 10:00 PM. And I was asked how to find the time to improve the coding skills and become a competitive programmer.

There are risks to spend time working on the data structure and algorithm. Since we only have limit hours to work on coding every day, sometimes if we do spend time on training, drills for practicing data structure and algorithm, then we will find that we are short of time to deal with daily tasks.

Just trust that the practice and drills will make you a strong player. Find ways. Write best code in the world, most elegant code with style called readable, clean as possible.


Train insane or remain the same


It is my favorite quote to encourage myself to train myself. 

Professional tennis players train themselves, in order to play 2 or 3 hours matches, they practice hundreds of hours. Hitting partners, mental trainers, coaches, and all kinds of get-together practice with peers, there are a lot of people get involved with training. Sports is fun to watch, but all those hard work and training is tough to go through. Same as I train myself to develop crafting skills, it is hard and it is not easy at all.

Coding skill is like the weight control project. In order to stay fit, we have to change life style, related to my own case, I have to be a sports player, and also need to study everything about tennis. Also I have to control my diet, and choose to eat unprocessed food as possible. Coding skills is the same. 

We have to learn how to take care of ourselves as a individual contributor, as a software programmer. Work on crafting skills, share and document the practice, journal the practice and keep improving. I also learn to encourage other peers do the same thing, it is not easy to work on training.

Code study 


Best and quick way to evaluate myself coding skill is to find some code I write. It is hard to learn the fact that I was not a good programmer at all back in year of 2013.

I shared my coding sample back in 2013. After full time work 4 years, I could not write a short and clean code in less than 15 lines. Instead of the clean, readable code, I wrote over 80 lines of code to make me try to hide the sample code 3 years afterwards.

What I did in last 3 years is a lot of challenge work. I have to work on so many issues. 

Pull all gists from github

Dec. 21, 2017


Introduction


As an owner of coding blog, I like to download all 1000 gists on github to the local computer. What I do is to google and find ideas to solve the problem. Once I have 5 - 10 minutes, I will search google and find some ideas to work on this small project. I found some python code to download the gists from github before, but today I like to give it a try.

Some progress


Dec. 21, 2017

As a github user, I also like to learn how to use github day by day. I do not want to do labor work, download one by one, do it 1000 times. Today I came cross the blog related to "pull all gists from github", here is the article link.

I read the python code, and then ask myself how to run bash script on windows. I search google and then I found that I need to install cygwin. And then I installed cygwin first, and then chose to install curl and then python3. I ran the code and I got some downloads.

Unfortunately, the download stopped after only 30 gists are downloaded.


Github API


Plan to study github api, and then I can solve more problems in the future.

Write down the date if I study API more than 30 minutes.

Wednesday, December 20, 2017

Code review: Leetcode 10: regular expression matching

Dec. 20, 2017

Plan to code review a dynamic programming solution to solve Leetcode 10: regular expression matching.

Here is the source code with the analysis.

I reviewed the above code, and rewrite the for loop using while loop since I do not like the loop variable in the for loop is changed inside for loop. I choose to use while instead.

I have some issues to rewrite the logic in the giant expression from line 57 to line 58 but had some issues to fail some test cases. So I keep the style even though I do not like it. I will figure out the issue later.

Here is the C# code.

Design review

Dec. 20, 2017

Introduction


I had a mock interview at 10:00 PM with a peer. After the mock interview, I asked the object-oriented design question, and the peer wrote down his idea.

Here is his writing, the idea is very clear to use interface, class, and the API design.


Also, the peer shared with me two design interview links.

https://github.com/donnemartin/system-design-primer

https://github.com/checkcheckzz/system-design-interview

Find the running median on Hackerrank

Dec. 20, 2017

Introduction


It is another 10:00 PM mock interview, I had chance to talk to the peer after the mock interview. I asked a few algorithm for him to solve, and then he advised me to watch Hackerrank Cracking the Coding Interview Challenges on the algorithm Find the running median.

Find the Running Medain


Plan to study some C# implementation and see if there are very good code to study.


Tuesday, December 19, 2017

Every good coding blog needs a revisit

Dec. 19, 2017


Introduction

It is interesting to learn how those peers develop their career by revisiting their blogs. I revisited one of blogs I blogged 2 years ago, and then I found out that the peer is an excellent coding blogger.

It is my time to review Leetcode 20 algorithm, and then I came cross this blog with the implementation of Leetcode 20.

Here is the blog written in Chinese. It is so interesting to study how good Chinese programmers are.

Blog study: OO design PH.D.

Dec. 19, 2017


Plan to study blogs written by a PH.D. graduate focusing on object-oriented design. Here is the blog.

My favorite reading today are the following:

1. Design model talk, here is the link written in Chinese.

2. Talk about mathematics as a software programmer, the article link is here.

3. Java design - the book link is here.

Follow up 


Dec. 15, 2017

Here are the articles I like to read carefully. 

design pattern java - the link is here. 

Leetcode 20: Valid Parentheses (II)

Dec. 19, 2017


Introduction


It is very hard challenge to plan what to study and what to review in this holiday season. Specially I will have a holiday break in the last week of December.

On Dec. 18, 2017, I practiced the mock interview, and then the peer worked on the valid bracket algorithm. The peer is a young undergraduate student who just started his computer science degree in university of Washington, top ranking computer science. The peer just started this year.

What advice can I give to the peer? I was asked by the peer.

I knew that it takes some time to develop the mock interview skill. But it is good to take the hint, and also follow the peer's idea. I was stubborn before on one mock interview when I met a computer science undergraduate from UCLA, and I learned the lesson on this algorithm called the largest smaller key in BST. I explained the idea to follow the hint to the peer.

Addition to mock interview 


It is a good idea to extend the algorithm for the mock interview algorithm. For bracket match algorithm, there are a few algorithms from Leetcode. I reviewed one of them called Leetcode 20: Valid Parentheses, and then I like to write down my review one by one.

Here is the blog I chose to study in January 2016, I also created a gist for the blog. The blog author wrote 170 blogs in Chinese, and he wrote very well. And also I found out that the blog Ethan Li 的技术专栏was written in 2015, now the peer works for snapchat, a facebook company.

I did great job for myself today, find 170 blogs to read related to algorithm, analysis and very nice readable code. It is hard for me to keep learning new algorithm while taking mock interview every week day 10:00 PM. It is better for me to read a lot of coding blogs, and reduce time on wechat related to social stuff.

I will choose five algorithm written by the engineer, and then write a blog for each algorithm.

Blog study: OO design PH.D.

Dec. 19, 2017

Plan to study blogs written by a PH.D. graduate focusing on object-oriented design. Here is the blog.

My favorite reading today are the following:

1. Design model talk, here is the link written in Chinese.

2. Talk about mathematics as a software programmer, the article link is here.

3. Java design - the book link is here.

Follow up 


Dec. 25, 2017
It is now 5:39 PM. I have mock interview in less than half an hour. I like to update my blog about reading progress.

I could not believe that I was too busy to read the article from the professor. Today I found a good article to read in 10 minutes. Here is the link to talk about template method.

Monday, December 18, 2017

Leetcode 32: Longest Valid Parentheses (I)

Dec. 18, 2017 


Introduction


Longest valid parentheses is the hard level algorithm and is one of Leetcode algorithms. 

Back to January 2016, I did not know that Leetcode discussion panel has so many solutions. I always tried to google and found the solutions. Here are my favorites back in 2016. 

Code study 


A Chinese blog with more than 8,000 views. The link is here. 

To learn the algorithm, in case the study blog may be retired some day,  I start to put analysis in my gist as well, the link is here. The Java code is here. 


Actionable Items



Review more blogs:

http://bangbingsyb.blogspot.ca/2014/11/leetcode-longest-valid-parentheses.html

http://shanjiaxin.blogspot.ca/2014/04/longest-valid-parentheses-leetcode.html

Julia C# practiced the algorithm in January 2016, here is the code.  



Leetcode 20: Valid Parentheses (I)

Dec. 18, 2017

Plan to review the algorithm called Valid Parentheses. It is the easy level algorithm. 

Last practice in 2016 is here. Another version is here. 


Here are the blogs I chose to study in January 2016, documented in a blog here:







Actionable Item


One thing I like to do is to break the blog written in January 2016 into multiple blogs, I may study a lot of hours on those algorithms. It is better for one blog for each algorithm. And also one blog for each good idea for Leetcode 20. 

Make life easy, specially learning algorithm should be more organized. 


Leetcode 22: Generate Parentheses

Dec. 18, 2017

Plan to work on Leetcode 22: Generate Parentheses.

It is medium level algorithm. My last practice is here, back to 2016.


Sunday, December 17, 2017

Code review is fun

Dec. 17, 2017

Introduction


I spent 10 minutes to review the algorithm written in C++ after I spent over one hour to write a  C# version of Leetcode 4: Median of two sorted array. The code in C++ is based on the work I presented and the peer made some simplification in C++.

I like to give a quick and short code review.

Code review for fun 


Here is the C# code I wrote.

Here is the C++ code I like to review.


A variable written in r on line 9 can be understood using multiple meanings, it can last index of the array, or it can be the length of the array, and interview is kind of competitive programming, under pressure you will confuse yourself as well, time is limited to 30 minutes. So if you write something which is verbose, it is good and it is self-explanation. 

Of course, coding style can be picked up in less than a few hours, as long as the algorithm is correct you should be ok. Most important is the strength of algorithm analysis itself. But you certainly should ask the interviewer his/ her style. 

FindIthElement -> FindKthSmallestElement, if it is private function, then in C# starting from lowercase. The function name should be called findKthSmallestElementThroughTwoSortedArray, the name covers every detail of function arguments. And also one more thing is missing in the title, it should be called findKthSmallestElementThroughTwoSortedArrayWithGivenStartIndexes. 

Do not laugh at me. I am just acting like a teacher, or an interviewer. 



Michael Mmoh - ATP tennis player study

Dec. 17, 2017

Watch the video of 10 minutes, the link is here.

Kyle Edmun - ATP player study

Dec. 17, 2017

Introduction

It is the best time in the day to study a player Kyle Edmun. I need the fresh idea how to develop myself as a recreational tennis player. And also I like to learn new things and know a new player.

Now it is 11:03 PM, I just finished 10 minutes of video called Kyle Edmund - Rising British Tennis start, Trans World Sport.

Code review: Find kth largest element in the union of two sorted array (Follow up)

Dec. 17, 2017

Introduction


It is so challenge to work with the algorithm called Leetcode 4: the median of two sorted array. It is hard level algorithm. I have been worked on the algorithm more than two hours today.

First I wrote a bug-free code based on Leetcode 4 online judge. And then I wrote a code review to review my own code Find kth largest element in the union of two sorted array (Follow up) written more than 10 months ago.

Here is the code reivew I did in last 60 minutes.


Actionable Item


It is kind of fragile thing to perform algorithm practice. In order to write bug-free code, I documented every step and it shows that it takes over 10 months to learn one algorithm related to binary search, and actually it also takes a senior level Microsoft engineer to help me to find the bugs after mock interview.

The algorithm is so hard to write and we have issues without a lot of test cases from Leetcode online judge Leetcode 4.

Timeline of algorithm practice


11 months ago, I posted the algorithm question on code review, here is the link.

With the feedback of JS1's code review , 10 months ago,  I posted second algorithm to follow up. Here is the follow-up.

Today I practiced my mock interview over 100th times since this March 2017, I always meet the highest top players who works hard to prepare top level onsite interview like Facebook or Google in less than one month.

I have to share my practice and then work more than 2 hours to work on bug fixes, and coding style and all other engineering stuff. Be a writer first instead of just writing code.

Today I wrote a code review to fix my own mistakes over 10 months ago. Here is the code review link.

Leetcode 4: Median of two sorted array

Dec. 17, 2017


Introduction


I had a mock interview at 10:00 AM, and after the mock interview, the peer asked me how to solve algorithm in Leetcode 4.

After more than 20 binary search algorithm practices last 6 months, I just gave a talk how to solve the problem.

Algorithm


The problem statement:
To find the median of two sorted array.

Optimal solution is O(lg(n + m)), n and me is the length of two array.

My analysis


If two arrays are sorted, and then we try to find each median of sorted array first, and then see how we can relate the median to those two median values.

So we can not merge two sorted array, since it will take O(n + m) to merge two sorted array using two pointer techniques.

The idea is to simple, each sorted array we divide into two halves and then we have to decide to get rid of which half.

Code to share


The peer was really busy but the peer said that if you have the code, please send me an email. So I thought about the problem and remembered that I worked on the similar problem and asked code review before.

I was so proud of myself, so I sent the link. In less than half hour, the peer sent me email about test case failure.

Here are the report about complaint.

Input: [1, 3]
[2]
output: 1.00000
Expected: 2.00000

So I started almost 90 minutes to debug my code.


C# code review 


Here is the C# code to pass all test cases on Leetcode 4. 

And then, I wrote an email at 3:27 PM to the peer, here is the email I wrote:
Thank you to point out problems. Here is the code to pass all test case of Leetcode 4. 


 I modified the code based on your input. 

 First, line 10 I prefer to use meaning variable name, firstIndex, whereas line 12 lastIndex is used. 
 Line 30, 32, and 39, the function getKthLargest function is used. Remember that kth smallest number is matching your original input. 

 The rest are the bugs in my code, a few of bugs:

 1. line 52, add +1 to the formula nthSmallest, this is missing one bug. 
 2. line 74, it should be start2 + k - 1, missing start2
 3. line 79, should be start1 and start2, not 0, 0
 4. line 86, 87, missing start1 and start2
 5. line 97, missing start1
 6. line 113 missing start2

That is all. I am surprised that my code has 6 bugs. Without Leetcode test cases, I write buggy code. 

Sincerely, 


jianmin chen 

And the peer sent me an email saying that: Me too 😊

Actionable Item


Need to put some review on code review, fix the buggy code I wrote.




Leetcode 10: regular expression matching

Dec. 17, 2017

Introduction


It is the best mock interview so far I have. I met a very senior developer working in Seattle area, and then I have to work on the algorithm called regular expression matching.

It is the challenging algorithm and very classical. I was told to work on dynamic programming and the peer likes to help me to work on the analysis and coding. But my argument is if I write a recursive with memo correctly then it should be easily applied to dynamic programming.

Code review


Here is the code I wrote in mock interview. The peer gave me instant feedback right away, and also wrote comment right away while I write first few lines of code.

Line 44 - 53, the code failed 6 test cases, only passed two test cases. I was told by the peer that I missed the test case like "" match pattern string "a*b*.*".

Also line 51, if the pattern string has only one char, it should return checking (char == '.'). The peer explained to me by adding the comment, using test case to help me understand the bug.

I fixed the variable issue on line 61, patternIndex variable should be used instead of using textIndex.

It is time to say great thanks

Dec. 17, 2017

Introduction


I start to write a series of blogs related to "It takes village to raise a child". As a software programmer, I notice that I have developed so much confidence in writing clean code, readable code, self-documented code in 2017. People are so busy but they still find a little time to read my blogs. And then they are so busy but they like to share their experience with me through short phone conversation. It touches my heart every time I meet in person and talk through the phone. I feel that the world is so connected and I am making new friends. And also I start to understand the programmer job is actually people oriented, I have to reach out for help.

So it is my turn to write some thank you note to all the people working for various companies in 2017. Without those encouragement and feedback, I may be still the same quiet hard working lady, write coding blog every day, but now I am happy and healthy, make small progress every day, and  fully enjoy the beauty of coding.

My argument is this. Act like a super talent programmer, and then always find the joy to review the code, write a better one with more efficient, much better coding style, and also with advanced design of object-oriented. Now I spend less time to debug my code, and I always find myself to write a simple code.

Thank so many companies in 2017 to help me grow so well as a software programmer.

Amazon - January - Make my January so special and so challenging.

Google  -  February - Make me so excited, even though I experienced first car accident in my life in the same day, I learned to get more prepared for worse or for good thing in life.

Vision Critical - May -  Make me feel so special.

Copperleaf - I understand that how math can change the world, specially in financial industry

Refdash.com - I understand that every mistake I make in one hour mock interview, I also make  another great mark to show my progress.

Pramp.com - This is such a great company and I have chance to meet all over the world top talent people.

Amazon - July -  I worked so hard to push the limits to advance my coding skills.

Global Relay - September, Operating system question can be so challenging and great time to think about.

Microsoft - October - It makes me so excited to know how a start-up runs in the big company. So exciting to know the company and an engineering manager.

Amazon - October - I really like to think about work when I took vacation in China, I will try to compete again.

Stackoverflow - November - I always get the best advice and find my weakness in my skills.

Expert Roundup: Online Courses & Coding Bootcamps

Dec. 17, 2017

Plan to read the article first, and then look up more through google. Here is the article link.


Saturday, December 16, 2017

Learning to program: finding the best path that fits you

Dec. 16, 2017

Plan to read again the article: learning to program: finding the best path that fit you.


Css file does not get uploaded to browser

Dec. 16, 2017


Introduction


It is the administrator's work to make sure that the web browser will display latest Css file, I came cross the issue recently and I did some quick fix, add a version number after .css file.

I like to write a blog and carefully review the issue. Document the progress first, and see what I should do to keep working on the issue.

Follow up


Dec. 15, 2017

Set 1 minute expiration on the webpage
https://blogs.msdn.microsoft.com/rakkimk/2007/07/09/iis7-how-to-enable-content-expiration/

https://stackoverflow.com/questions/35969498/iis-8-0-add-both-expires-header-and-cache-control

How to get latest .css file?

https://stackoverflow.com/questions/15562384/how-to-force-chrome-browser-to-reload-css-file-while-debugging-in-visual-studio

Follow up


Dec. 18, 2017

Download Fiddle web debugger, and then try to figure out why the latest .css file is uploaded automatically.

Actually the .css file is not invoked by Fiddle log history at all.

Paysa 2017 top tech companies bonuses and employee retention

Dec. 16, 2017

Introduction


I read the article in Chinese on wechat, so I like to do 10 - 20 minutes study and also write a blog. I found the article in English, titled comparing top tech companies bonuses and employee retention. Here is the link.


Dynamic programming should be daily practice

Dec. 16, 2017

Introduction


It is hard to get used to write bug-free code for dynamic programming. Specially base case handling.

Here is C# code I practiced on Dec. 16, 2017 10:00 AM. The code I wrote had a bug to handle the array with length 1, the product should be 0 instead of 1.

Feelings


This practice I felt much better. First I read the problem statement loud, and then I spent over 5 minutes to go over the test case, and explained the brute force solution and its time complexity. And then go to optimal one, how to apply the two linear scan integrated with left neighbor or right neighbor products with one more multiplication.

First try to explain very clearly the idea, and then it is very easy to write the code just following the idea.

I have practiced this algorithm more than 4 times since March, 2017. I still made an error on edge case. I just added tags for all past practice using Leetcode 238: product of array except itself, so I can easy go over the past practices and review them.


Get organized


It is most important task to get organized, review every practice in one setting. So I can figure out how I develop good understanding of the problem through each mistake, and also get some ideas what to work on next.

Source code is the key information to document how good/ not good I am in terms of algorithm analysis, coding style, and also whiteboard testing.


March 21, 2016, here is the blog about the practice.

Oct. 29, 2017, here is the blog about the practice.

Dec. 16, 2017 practice is Here.

Thursday, December 14, 2017

Choose to be Maria or Matha

Dec. 14, 2017

Introduction


Bible story Mary Listens while Martha Labors (Luke 10:38-42) is my favorite, and I like to have wisdom to listen instead of worrying about so many things. And I want to write my mock interview experience and mainly reflect on my feedback. 

After both of us finished the turn to be interviewed, the peer told me that he tried to give me hint when I worked on the algorithm, but I did not give him chance to talk. It is not so good since I should pay attention to my peer. 

Also, I broke my promise to write optimal solution with time complexity O(logn) and space complexity O(1), but I just started to write at the very beginning to declare an array with space n, and copy the array to the new array using time complexity O(n). 

Am I a good listener? I learned the story of Mary instead of Martha more than 15 years ago when I was in Florida, United States. I will read the bible story, and try to relate the story to my mock interview feedback. 


Mock interview


It is another normal mock interview, my peer did not show up so mock platform matched me with one 10:05 PM. It is the algorithm I worked on before, the last practice is documented in the blog in Sept. 2017.

C# code is here. The code passes all test cases but time complexity is O(n) not O(logn), the space complexity is O(n) not O(1). I will make quickly change to remove diff array and integrate the checking with difference value arr[i] - i where arr is the integer array and i is the index.

After I performed the algorithm, the peer said that he never met any one like me before. He liked me to present the analysis first, and the way I wrote the code to solve edge case, find lowest index with value arr[i] = i is very efficient. The peer gave me hint how to make the minor change from line 34 to line 46, I just said that let us work on simple example, [0,0,0,0,0] is the array with five zeros, how to find the first zero index, which is 0?

I analyzed the test case first, and then I said that I do not want to scan the array from middle index to left, I need to do binary search as well. I explained the idea but the peer said that he could not understand it. So I wrote the code line 39, and explained that I need to make sure that left neighbor is existing and its value is 0 as well, so I will do another binary search.

Follow up after mock interview


I like to write the code based on mock interview code, and then remove the code to declare extra array from line 14 to line 17.

My last three practices on the algorithm are here:

1. June 8, 2017    (.ca)
2. Sept. 4, 2017   (.sh)
3. Sept. 14, 2017 (.mp)

All the above 3 practices have issues, need to do code review.

June 8, 2017 practice is here. Sept. 4 practice is documented here. And Sept. 14 practice is here.

The C# code written in Dec. 14 is reviewed after the mock interview, and the code is here to fix the bug, time complexity and space complexity is lowered to optimal ones.


Lesson learned 


This mock interview I practice to read loud the problem statement, not in rush, complete the reading and also let the peer hear. Because I read the problem statement loud and slow, I found that the smallest index has to be found and it is a challenging task to achieve the goal. I just cannot miss it since I read loud and slowly, and use gentle voice to calm myself down.

The reading part is also very important to practice in the interview, do not try to read silently, speak each word clearly like an actor/ actress to read the script in Suits. I plan to write a blog about watching the video script reading.


Feedback from the peer


The peer has great education and also very good work experience in Seattle area. The peer mocks for fun.



Quora study: Carlos Garcia Jurado Suarez

Dec. 14, 2017

Introduction


I read news feed on quora.com, and then I read the answer https://www.quora.com/Is-the-technical-interview-at-Facebook-easier-than-that-at-Google Jessie Su voted, I do not like the answer. So I read more on the question, I found one answer I like and also I find a lot to read. Big achievement for the day, Dec. 14, 2017.

The author of answer is called Carlos Garcia Jurado Suarez. I like to read those blogs related to career and continued education.

What a name, I know Spanish a little bitter more now.

Blog study


https://codepointers.com/

So sweet holiday message from Quora

Dec. 14, 2017

I got an email from quora about 2017 summary on Dec. 14 2017.

Here is the statistics I got from the email.

Will show some graph here. Good design and so happy to go over those numbers.


The design is very good. But I like to question a few things on the design or layout.

What is world's knowledge? Please clarify, a new term, I never hear the term before. It sounds like academic term, it should say that serious writer/ reader will like to write somethings to contribute the world.

I like a lot of users are not anonymous and share their knowledge, but my concern is that a lot of talk without any action. I try not to consume too many content from quora.com.




Code review: Calculate steps

Dec. 14, 2017

Introduction


I am comparing two versions of code, and tell what is the difference between two peers. One is current one who passes phone screen, and another one who failed second phone screen.

Here is the code.


Code review: convert to string

Dec. 14, 2017

Introduction


It is true that the peer I meet is developing new skills every day, soon or later, the peer will become very powerful programmer once the peer lands the first intern role.

Code review


The Java code written by peer has two issues, base case is missing 1 - 9, only 0 is considered in the base case. The recurrence formula is not designed properly. It should be rightmost digit stays after the recursive function's return.

Here is the code with my review.


Design challenge using object model

Dec. 14, 2017

Introduction


It is the learning experience to figure out how strong the peer is in terms of object-oriented design. So I asked the peer the question and I got some writing from the peer. I like to review the design later.


Problem statement


Let's say we're developing a vector graphics application. It will allow the user to create lines, rectangles, circles, text, etc. and manipulate them independently - move them, re-size them, etc. Design an object model for this application.

• How would you model the representation of the document in an object oriented language?
• What classes would you define?
• What methods would you have? What would your API look like?

Answer:

class shape{
    int x0, y0;
    int area;
    int[] getCoordinate(){
    }
    int getArea(){
    }
    void changeCoordinate(){
    }
    void changeArea(){
    }
}

class line extends shape implements Drawing{
}

class rec extends shape{
}

class cir extends shape{
}

class text extends shape{
    int x0, y0;
    int area;
    string content;
    String getContent(){
    }
    String changeContent(){
    }
}

class Pen(){
    Shape drawShape(){
}

class Drawing(){
Interface Drawing
{
}

Graph draw(Shape shape){
}


Julia's review


Think about S.O.L.I.D. principles, and also think about C# string class how many interfaces are implemented. Julia has to figure out how to do better by herself as well.

Follow up


Dec. 19, 2017
Plan to read those two blogs related to UML diagram.

1. Study UML graph, the article link is here, another link is here.

2. a blog related to UML graph, the link is here.

Proud to be a peer

Dec. 13, 2017

I practiced with the peer together on Nov. 4, Nov. 7 to help peer prepare for onsite interview in Nov. 2017, and on Dec. 13, 2017, the peer told me that he got the offer. I could not believe that I am becoming very good partner to prepare for important onsite interview. I like to review two algorithms we practiced together.


Leetcode 611 valid triangle number

Divide to n small linked list

Base case

Dec. 13, 2017

It is a long mock interview for me, I worked together with the peer second time, the first time was less than a week ago, the blog is here.

We worked from 10:00 PM to 12:40 AM. I asked two more questions to interview the peer.

The peer helped me to write an algorithm related to recursion, memoization, edit distance problem.

Code review

The C# code is here.


Follow up

After the mock interview, I realized that the memoization has issue. I should declare the memo jagged array with size new int[length1 + 1][length2 + 1] instead of int[length1][length2].

The memoization should record the value for the top row and top column.

Line 42 and line 47.

One thing I can do is to test the code using Leetcode online about memoization design issue. Another one is to read dynamic programming solution, and check the two dimension matrix and its size, base case handling.

The peer brought up a lot of good discussion about the code, I changed the structure of the code to remove redundant code from line 62 to line 73.

Object oriented design case study

Dec. 14, 2017

Introduction


It is time for me to review object-oriented programming, since I start to read C# string, array abstract class, I start to develop a lot of interest, and also I like the lecture note since it is so well prepared. I wrote my lecture note study recently in the blog.

Here is one answer I did back in 2013. I like to review and see if I can do better this time.

Wednesday, December 13, 2017

Convert to string not using itoa similar function

Dec. 13, 2017

Introduction


It is challenging to review the code I wrote back to Oct. 2013. I like to review the code as I did review code 8 years ago. My last blog was written in the blog titled: Algorithm: possible triangle.

Time line: Oct 2013


Here is the code I wrote in October 2013.

Time line: Dec 2017


Here is the code I wrote in Dec. 13, 2017 using recursive function.

Here is the code I wrote in Dec. 13, 2017 using iterative solution. Need to work on a simple version, I like to practice and learn some APIs, so I kept the version for my learning.


Code review 


I like to review the code written in 2013, the code is here.

Analysis of algorithm


First, the analysis of the algorithm is good in 2013's code, but it takes 10 minutes to write, it should take less than 5 minutes.

The whole paragraph should be organized better. And the comment should be written in the following based on my understanding of depth first search, I learn a lot from Hackerrank contest recursive function failures.

Depth first search


Use depth first search to do the work, recursive function can be designed in the following:
Do at least as possible, smart programmer learns math in computer science first. Being lazy is the status of master of math in computer science. Read more book called basic mathematics in computer science and figure out the depth first search, only thing I need to do is to figure out the base case.

What is base case? One digit number, just output new char[]{(char) (n + '0')}.

What is recurrence formula?
We handle the rightmost digit first, so the string can be concatenated as recursive + base case. If the integer is negative number, '-' should be the first char in the string.

How to get rightmost digit? use % operator, and then work on subproblem which is n/ 10.

Good things in the writing on Dec. 13, 2017. Algorithm is specified using depth first search, recursive function. And then the base case is clearly explained in the paragraph. And then recurrence formula is easy to work on.

Code execution


Let me go over line by line.

1. Line 20, int[] should be char[]. Return type is char[].
2. line 23, return char array, should be new char[]{'0'}, not "0".
3. line 28, do not change function argument. Declare a new variable.
4. line 25 - 30 should be written in the following:
var isNegative = n < 0;
var postiveOne = isNegative? -n : n;
two lines instead of six lines.
5. line 31, comment: "at least I have one edge case, continue later. need idea?"
Remove the comment!
6. line 37, for(;;), use while(true)
7. line 39, digitOne variable should be rightMost.
8. line 48, 49, move at the beginning, emphasis that it is the base case.
    if( loopInt < 10)
   {
   }

Overall, the code is not structured very well. The code should be self-documented. And the code is written as an iterative solution, but recursive function should be quick and easy solution to write. I was not a very good programmer back in 2013, I have to face the reality after the review of the code.

What happened after 2013?


Let us read the answer Julia wrote Top 10 reasons to write a coding blog on quora.com in 2017.


Action items


In order to punish myself do not focus on learning basic mathematics in computer science, I decide to spend at least 5 hours to learn vocabulary in the book, at least collect five hundred words. And those words will be posted here.

This is the drill I learned when I watch China Open tennis professional players did, after they tried to hit Mercede sign, the athletes have to do push up because she/ he fails.

Tuesday, December 12, 2017

Binary search practice

Dec. 12, 2017


Introduction


Binary search algorithm is getting easy to write and I wrote one more time on Dec. 11 10:00 PM mock interview. I wrote the algorithm using C# language and the code passes all test cases.

Code review


Here is C# code.

Line 50: return binarySearch(x, n start, end);

I forgot to write a recursive call as line 50 shows. After the whiteboard testing, I wrote the test case Root(7, 3) and then I found out the bug.


Follow up 

Dec. 19, 2017  10:14 PM

Binary search range should be discussed based on x value, if x > 1, then the search range is [0, x]. But if x < 1, then search range is [x, 1] instead.

The mock interview practice has a bug related to range to search.



Enumerable extension methods

Dec. 12, 2017


Introduction


It is a good idea to invest time to memorize Enumerable extension methods. I like to go over each API first, and then start to read LINQ and prepare myself for next project.

Here is the link.


Sunday, December 10, 2017

Binary search tree search from root to leaf node

Dec. 10, 2017

Introduction


It is the great learning experience for me to do mock interview tonight at 10:00 PM. I met an architecture tonight, the peer showed me how to write correct code first, and then reminded me to write optimal code as well. The search in binary search tree can turn left and then turn right and then turn left, but invariant is that the path is from root to leaf node, and the answer is always found until the leaf node is reached.

Code study


I practiced this algorithm so many times, last time I wrote a blog about the experience one month ago. Here is the blog.

Today I solved the problem with the help of the peer.

There are two bounds to work on. One is the lower bound value which is smaller than given value, and then the other one is upper bound which is smaller than given value. In order to find the upper bound, we are looking for the first value which is bigger than given value first, and then find a smaller value until one is found. Then we are sure that we are find the upper bound value.

In my previous practices, the upper bound value should be searched in two directions, go right to find bigger value, and then go left to find smaller value.

Feedback is encouraging


Follow up 


Dec. 13 ,2017

Finally I have time to come out a test case to illustrate the search, and the steps are left and right and left and right and left.

Here is the binary search tree, given value 7, the largest smaller BST key should be 6. How to find the node with value 6?

Start from root node with value 10, and then visit every node in the above tree, and visit the leaf node with value 6, and the answer is 6.

Code Review: Learn Trie from Leetcode 212

Dec. 10, 2017


Introduction


I posted a question on code review today, it is called Learn Trie from Leetcode 212. I got a comment to read patricia trie for space complexity, so I spent 30 minutes to read about it.


30 minutes reading


Here is one article I like to read, the link is Compressing Radix Tress Without Tears.


Mother Tesesa

Dec. 10, 2017


Introduction


Mother Teresa is the favorite character I know as a Christian. And I use her story to help myself to communicate with my sister back in China as well. Since we dispute on the immigration issue, do I make right choice to sponsor my nephew to immigrate to Canada? She insists that China is best place to develop a career and life, now it is not 20 or 30 years ago, young people choose to stay in China instead of immigration to United States or Canada. I think that Canada has best education system in the world, and also the young people have their own rights to make their own decisions.

I share my argument with my sister, life is not about money, how many income to have, how good the career you have. My role model is Mother Teresa, I do not want to compare myself to my sister or other classmates.

I always feel good to stay humble and make a living, struggling is good, learning is fun and life is also great without good wealth or health. My sister has never heard about Teresa before. So I also need to study more about mother Teresa, and hopefully I can be more educated and be confident to be myself.

Video talk 


Here is 19 minutes talk given by Mother Teresa, Acceptance Speech by Mother Teresa Media Player at Nobel prize org. I remembered that in Florida one time my friend in church shared me her story, talking about people can not afford a pair of shoes.

Saturday, December 9, 2017

Mock interview weekday 10:00 PM

Dec. 9, 2017

Introduction


It is the question a young graduate student asked me in mock interview recently, what is my motivation to practice mock interview? Am I preparing for interview or just for training and improving skills.

My story


I did write a blog on this topic before. It was more than four months ago. The link is here. The topic is to do your current job well. We have to learn how to serve the current employer very well. A lot of uncertain things will happen in the job, we have no control at all. But we can choose to do thing easy to be controllable, keep practice mock interview, keep meeting highly talented programmers, keep practice those thirty algorithms again and again on mock platform, learn one thing a time, practice one algorithm a time, learn from one peer at a time.

In order to get really good on one algorithm, I also ask the question on code review stack exchange to get more input from the general public.

Training is like favorite sports I like, tennis. I learn from professional tennis players, follow them on instagram every day. The top tennis professional players are very good to market themselves, educate the fans what is really a sports professional, I just learn how to do interval training from 詹詠然 Latisha Chan , problem solving skills. My favorite players are Alize Cornet, Elena Vesnina, 詹詠然 Latisha Chan.

We know that the algorithm and data structure plays so important role as a software programmer. We also know how the technology makes our life so enjoyable and so rich. We actually change the world through our daily work as software programmer. We have to train ourselves like professional tennis sports players do. To expedite daily problem solving, write highly self-documented code, and keep updated with latest trends in education, technology and hottest market - competitive career and job search, one of training I choose to do is to practice mock interview daily at 10:00 PM. Keep working on crafting skills, communication skills, whiteboard skills, the rest will come naturally.

New story


Through those hundred mock interviews, I learn to work on the same mock interview algorithm again and again. I actually train myself to learn various things, coding style, testing, and also new features in language, a new language, how to help and communicate, experience tough time, deal with tough situation. I document all the experience through coding blogs.

I used to write so complicated code, and worry about bugs. Every time I make code change I worry about all kinds of issues. One time I remembered that I may mess up existing code in the same function, for example, the function I have to work on is too complicated and it will take some time to rewrite and test them. Right now, I understand that it is more important to write with good coding style, good code principle instead of just making it work, I kill the code right away and start to write clean code. Zero tolerance on bad coding style, zero tolerance violation of coding principles like DRY, SRP, S.O.L.I.D., TED principle.


Education of computer science

Dec. 9, 2017

Introduction


It is normal 10:00 PM mock interview, but this is the first time I met a Chinese and also there was issue about audio through mock platform. I suggested to use skype phone number to get audio, instead the peer suggested to use Wechat to get audio. There are two algorithms involved, one is spiral matrix print for me, one is Sudoku solver for the peer. We talked about the algorithm and reviewed the code for one hour, and then we spent time to share the experience through wechat until 12:40 AM. It lasted 2 hours 40 minutes.

Backtracking bug


The peer wrote a Sudoku solve with a back tracking bug. I told the peer that Let me review the code and also help to find the bug.

I gave advice on coding style. Do not use i, j instead of using row and column.
Suggest to calculate the next row/ next column and express the intent to calculate.
Write first line of code in the function to discuss base case.
Remove if/ else and nested if/else, make the code flat, avoid smell of arrow-like code.
Most important is to discuss the backtracking and why it is so important to do it.

I enjoyed the discussion, I did see that people do not do backtracking and code still passes all test cases before. This time the backtracking has to be done, otherwise 5 out 7 test cases failed.

For example, Sudoku first row:
5 3 _ _ 7 _  _ _ _

For example, first _ can be filled with 9 possibility, from '1' to '9', for example, for example, '1' is tried, and then continue to second _ which is row 0 and column 3, '2' is put into trial. If '2' fails, then second _ with index of (0,3) should be backtracked to be filled '.'. We need to go back to the first _ to try next available number.

I showed the peer things to work on. Also I learned from the peer through his experience, he had 8 phone interviews for intern, 2 rounds of phone interview for interview, he definitely almost made it. Apple, Facebook, Uber and Microsoft.

All advice are from the code review on stackexchange.com, the question I posted over one month ago.

Talk of graduate study 


First document some facts about computer science graduate study and questions and answers:

1. It is hard to get in the computer science master degree program in Northwestern university. The tuition is expensive compared to Santa Clara university, $18,000/term vs $9,000/term.

2. To get a computer master degree, there are 45 credits in the program, non-thesis program. The tuition is around 45 thousand dollars, each credit costs $1,000 dollars. Private university, same tuition for international or noninternational.

3. Around 100 computer science master degree student, half are Chinese, half are Indian.

4. What is advantage of studying in Sillicon Valley?

5. How many of them get intern at Facebook or Apple? Compare to Waterloo university in Canada undergraduate program?

6. What is policy of work visa in USA? OPT or summer intern, 60 days limitation.

7. What is the like to work full time? Do you experience the tough algorithm similar to Leetcode algorithm?

8. What is difference between students with Leetcode practice and full-time programmers with same practice?

9. Rent fee in California, $800/ month for one room or $1100/month to share 2 bed/ two bath condo.

10. Teaching and learning in the university, what is difference? Santa Clara university vs Northwestern university.

11. What is my motivation to practice mock interview?



Suits TV show money talk

Dec. 9, 2017

It is time for me to look up the pay of Suits TV show. I read the article this morning. The article is here: Cast Of ‘Suits’: How Much Are They Worth?

Thursday, December 7, 2017

Binary search algorithm is very classical

Dec. 7, 2017

Introduction


It is learning process to practice mock interview. So many things are not under control. For example, today I attended 10:00 PM mock interview, time passed and I was matched with one after five minutes passed by. The peer said that the laptop has camera and audio issue, if I like to stop then I can do that. I offered my cellular phone number to make a phone call to get audio at least. And then the peer joined with audio on.

Binary search is such a challenging algorithm, I observed how the peer wrote code but somehow I did not take my opportunity to step in, gave the peer some hint to put the peer back in track.

Feedback 


Here is the evaluation I got. I need to work on communication.

I need to learn how to take mock interview seriously, no matter what happens at the beginning. Treat the peer like my customer. I have to show the peer how good I can solve binary search algorithm, it is give and take, win win solution. My best solution is here, I just got it after more than three practice. It does not matter the array is ascending order or not, I will get rid of half of array in my search each step. That is showing my attitude, head on to solve the problem.

Do not hold grudges. I still remembered that I waste hours to try to simplify the algorithm recently. Here is the blog about my last practice.

One bible verse to help 


It is good practice to review some bible verse before or after mock interview. Today I like to choose this bible verse help me to improve. Also I like to take chance to learn a few words. This bible verse is hard to remember word by word. I will give it a try next few days.

Ephesians 4:31-32 ESV / 694 helpful votes 

Let all bitterness and wrath and anger and clamor and slander be put away from you, along with all malice. Be kind to one another, tenderhearted, forgiving one another, as God in Christ forgave you.


anger
bitterness
clamor (?)
forgiving
kind
malice
slander (?)
tenderhearted
wrath (?)

Remember Chinese version first:

以弗所书 4:31-32Chinese Contemporary Bible (Simplified) (CCB)

31 要从你们当中除掉一切的苦毒、恼恨、怒气、争吵、毁谤和邪恶。 32 总要以恩慈、怜悯的心彼此相待,要互相饶恕,正如上帝在基督里饶恕了你们一样。