Saturday, July 8, 2017

Leetcode 151: Reverse word in a string

July 8, 2017

Introduction

 

It is the learning process to implement the algorithm Leetcode 151 using JavaScript. Plan to do some study and find out some code on Hackerrank or Leetcode discussion implemented in JavaScript.

It is very good experience to watch a peer to write a JavaScript, and then Julia took some time to compare her JavaScript knowledge to the peer.

Algorithm in JavaScript 

 

 

Will come back to work on the algorithm in JavaScript later.


Previous practice on Leetcode 151 is here. 

Plan to read Javascript Array.prototype.reduce  10 - 20 minutes. 

John Robert's best advice for young people

July 8, 2017

Plan to watch the video 18 minutes - graduation advice 2017 by John Roberts.

Not afraid to fail. Try again and fail again.

Lonely from time to time, so you do not take friends for granted.

Failure let you know the importance of sportsmanship.


Thursday, July 6, 2017

Leetcode 10: Regular Expression Match - dynamic programming

July 6, 2017

Continue to study a DP solution, discussion link is here.
Dynamic programming solution - practice code is here.

Another dynamic programming solution is here. Plan to study the code later. 


Study simple test cases and get more ideas how to design dynamic programming solution, code is here. 



Test cases

1 . test case 1: 
"aa" matches pattern string "a*". a* counts as multiple a. 

2. test case 2:
"a" matches pattern string "a*". a* counts as one a

3. test case 3:
"a" matches pattern string "a*a". a* count as empty

4. test case 4:
"" matches pattern string "a*b*c*". This is the base case. The string is emtpy string. 


Dynamic programming is such a difficult solution to go over with. It is a good idea to write the code which can be memorized and also easy to  reproduce based on a few of basic rules. 

Regular expression matching is a classical algorithm, it is best for the player to train and get some experience how to design a dynamic programming. 

We like to talk about base cases, talk about how many options for a*, zero or 1 or more 3 cases. We like to talk about the matrix starting from (0,0) and to (n,m).

----------------------------------------------------------> left
|
|
V top 


(left-2, top)   (left, top)         (left+1, top)
   

                (left, top+1)       (left+1,top+1)



Plan to spend 20 minutes to study the following notes in the discussion:







Leetcode 10: Regular Expression Match - One bug a time

July 6, 2016

Introduction


The regular expression match is the hard algorithm. Julia learns the algorithm more than five time last three months. She learns how to write the code in less than 20 lines of code, but also she learns to write the code with an iterative solution, ends up with more work and time-consuming bugs.



Algorithm Code Review 



Her practice using C# on May 16 is here. There are a few bugs in her writing.

Here are some highlights of bugs:
1. Line 27 - line 41, counter example, "" and pattern string "a*" or "a*b*". "" matches "a*"
2. Line 77 - 79,
3. Line 84
4. line 90

C# code with a bug.

The C# code passes all test cases. The code is here. 

Wednesday, July 5, 2017

How good are your people skills?

July 5, 2017

Introduction



It is the first time Julia likes to do some research to help her improve people skills. Julia plans to work on mocking practice every day around 8:00 pm in the summer time, it is challenge for her to meet every day with a peer and fully use 60 minutes to help both parties grow technically.

It is a good idea to do some research about people skills, how to be tactful.


A 15 minute evaluation


Julia worked the website and she did some multiple choice questions. Here is the link of "How Good Are Your People Skills".

1. Often
2. Often
3. Sometimes
4. Often
5. Sometimes
6. Rarely
7. Rarely
8. Often
9. Sometimes
10. Sometimes
11. Rarely
12. Often
13. Very often
14. Often
15. Sometimes
16. Very often



How to be tactful 




Here is the article link.


Tuesday, July 4, 2017

Leetcode 8: String to integer (atoi)

July 4, 2017

Problem statement

Last practice is in 2015, here is the C# code.

Algorithm to convert integer to a string

July 4, 2017

Introduction



It is so interesting to review the algorithm Julia wrote in 2014 called to convert integer to a string without using a library function like itoa.

Algorithm practice 


Two practices are here. First one is to write iterative solution, second one is to write using recursive function.

Implement itoa on geeksforgeeks, the algorithm link is here. 

Hourrank 22 - Candy Collection

July 4, 2017

Introduction


It is a great idea to find a hard algorithm to work on. The candy collection is the hard algorithm, which is related to segment tree. The problem statement is here.

Algorithm study 


Plan to work on the algorithm 30 minutes a time. 

Monday, July 3, 2017

Soft Skills The software developer's life manual

July 3, 2017

Plan to read the book called "Soft Skills The software developer's life manual" written by John Z. Sonmez.

It is the first time last seven years Julia starts to meet a peer and learn everything every day over 2 months. People share with her about their choice of choosing a computer science master degree, or Ph.D. program, or app academy program, how important it is to simplify the depth first search algorithm, how to conduct a whiteboard testing, what is the missing base case.

It is a new school for Julia to experience. Because of very high rating Julia has, it is not surprising that Julia meets top talent in the world quickly.

Julia experiences different soft skills through mocking experience. She also likes to read the book on this topic, and also blogs written by the author are much better.

Most favorite one - cooking at home.
5 subtle secrets of effective leaders - link is here.
5 Soft Skills Every Software Developer Should Know - 60 minutes video is here.

Bucket sort small talk

July 3, 2017

Introduction



Bucket sort is an algorithm Julia practiced a few time last 12 months. Here is one more practice, two blogs are related to the algorithm, called: Find the smallest integer not in a list.

Minimum Loss practice is here.
Stack overflow link is here.
GeeksForGeeks link is here.



Algorithm study and practice 

Sunday, July 2, 2017

Leetcode 10 - Regular Expression Match II

July 2, 2017

Introduction


Where is the best place to find better idea for an algorithm? Julia checked the hackerrank leaderboard, but for her practice of Leetcode 10 - Regular Expression Match, she googled using keyword, "Leetcode 10 C# solution", she found one today. Here is the C# solution in the dicussion panel.

Here is the C# solution she need to study today, and the algorithm implemented is better than Julia's one. She likes to study the algorithm.


Algorithm Study


C# solution using recursive, but no timeout issue. Solution is here.


July 5, 2017

Julia worked as the mocking interviewer 35 minutes on this algorithm, she had some issue to give out clear advise on the iterative solution.

In other words, there are 3 options with string "a" and pattern "a*":

a* counts as empty, why?  because it may be "a" and "a*a"
a* counts as single a, so, next will be string "" and pattern ""
a* count  as multiple a, so next will be string "" and pattern "a*"

July 6, 2017
Continue to study a DP solution, discussion link is here.
Dynamic programming solution - practice code is here.

Read an Amazon intern story in Chinese - link is here.

Another recursive solution - Julia's most favorite one
C# practice code is here.

Leetcode 10 - Regular Expression Matching

July 2, 2017

Introduction



It takes a lot of practice to learn one of the hard algorithm on Leetcode. Leetcode 10 regular expression matching's problem statement is here.

Algorithm Practice



Julia practiced the algorithm more than five times in last three months, she wrote more than two times in her practice as an interviewee, and then she mocked interview more than three people to work on the algorithm.

One of best codes is here written in Ruby, Julia met a very experienced programmer and then learned a few things. The code is here. Julia will write it using C#, and then try to run against Leetcode 10 online judge and see how many things are missing.

July 2, 2017 2:48 pm
Julia spent 40 minutes to work on C#, and the code is working except timeout issue. C# code is here.


Memoization Solution


One of the solutions is to use memoization to solve the problem. 

3:02 pm, Julia added memo as a Dictionary<string, bool>, to simplify the problem, assuming that " " is not used in regular expression matching, the code passes all test cases.

C# code is here.


No Memo Solution 


Julia could not figure out the solution by herself, so she googled and then came cross this solution through Leetcode discussion. C# code is here.  Leetcode discuss link is here. She wrote a blog about the solution, link is here.

July 6, 2017

One more recursive solution without using memo is here.

Problem solving



July 2, 2017 2:48 pm
Julia spent 40 minutes to work on C#, and the code is working except timeout issue. C# code is here.

July 6, 2017

To solve timeout issue, it is to early return the recursive tree, do not go over every node of tree.

Here is the C# code.

It is a brutal truth, Julia is not ready to be a professional interviewer or expert on algorithm. She could not spot the timeout bug in the code. She took more than 4 days and then figure out the bug. Right side is the C# code written in July 2 with a timeout bug, left side is the bug-free code.

The return statement with the format of "return A || B" will not run B if A is true. In other words, "return A || B" is not the same as
bool result = A; 
result |=  B;
The above solution to separate in two statements will cause timeout, since every branch of recursive tree will be executed. It is a fatal bug.



Inspired by the short and clean code, Julia continued to make the C# code short and clean. C# code is here.

One more step to simplify the code, code is here.

Summary 



It is so exciting to learn a hard algorithm through so many practice and code review. Julia worked with over 5 peers to solve the algorithm, she also wrote more than 5 times. Through the journal of the practice, she is able to track her progress and learn to solve the problem.

It is so much fun once the timeout bug is found through online judge on July 2. Julia kept reading more solutions until she found out the real issue - subtle bug in the writing.

Super Mancunian - HourRank 22

July 2, 2017

Introduction



It is a minimum spanning tree algorithm. But there is additional work to remove max cost edge in the tree. Julia started to work on the algorithm last 30 minutes, she spent 10 minutes to go over the problem statement and then figured out the whole requirement. She only had 20 minutes, she fumbled, and she looked at the leaderboard, checked players from Google's performance, she likes to write a simple code to score partial points to make her a medal player.

Too short time, it just reminds her that she needs to work on and review what she works on. She just needs to look into past work and then find a solution to score the points.

An algorithm makes her Sunday morning so challenging.

Algorithm 



Previous practice on Kruskal's algorithm is here. Julia spent wrong on the name, she spelled Krusal. In order to pay respect the scientist, Julia decided to review his wiki page and get more detail on his work.

Read wiki page as well. Plan to spend one hour to read this Sunday morning.





Saturday, July 1, 2017

Snack down finals 2017

July 1, 2017

It is so happy to read a blog from the very competitive algorithm player and problem setter.

A blog about algorithms, contest and maths - Aleigorithms.

The problems are here.

Three things to learn Canada day

July 1, 2017

Introduction


It is Canada day. Julia likes to celebrate the day as a Canadian citizen. She also likes to do some work for immigration application. Julia likes to work hard and plan to provide high quality work for the application.


Study and work 



Julia likes to do some research to help herself to get more educated on the application. She starts to find some videos on youtube.com.


Follow up 



July 3, 2017  5:55 pm

It is a long weekend. Julia did some study on her sponsor application. She spent a lot of hours to study youtube video about other people's sharing, and also she started to think about how to hold high standard for her own work. Professional consultant asks $3,000 Canadian dollars, after over 10 hours work and study this weekend, Julia found out the joy to go back to work on the case after a six-month -break, a return application just allowed her to see that her work based on 1,00 hours study could not compare to the professional consultant work. But Julia is a learner, she likes to get back and relax, try again, fail again, fail better.

As a software programmer, Julia could not take a whole weekend break only for immigration application, she still chose to work on algorithm mocking interview and practice for a few hours. But she learns to be gentle to herself, one mocking interview only. It took 100 minutes.

Bible teaching is here, Julia likes to share the bible verse to encourage herself to be a hard worker.
Proverbs 21:5 The plans of the diligent lead to profit as surely as haste leads to poverty.

July 8, 2017 10:55 am 

Immigration ranking: Lonely Canadian


It is so good to come cross the immigration law and learn how to apply to myself, commonly referred "lonely Canadian". Julia has a sister who has strong legal knowledge and she likes to question anything, so she read a lot and then she gave Julia an advice to look into immigration law. So after the conversation, Julia looked into the Canada immigration law, in less than 30 minutes, she found the law of sponsorship to apply herself. Sometimes it does not matter how strong you have the ability to do research, it is how you treat other people's opinion, how open you are to connect to people, be friends with people, fair to listen to people's opinion.

Learning a law is easy and apply the law takes courage and hard work.

Here is the video related to "Family Class: Sponsoring Overage Siblings".

Free webinar: Family Sponsorship for Canada - 19 minutes video link is here.


Follow up
Dec. 22, 2019

I walked in an office in crystal mall, the officer works on application for admission to universities, I asked her a few questions. And she also told me that even parents cannot sponsor their adult children if the child is over 22 years old. My nephew turned 25 years old this year.

I explained to her that lonely Canadian program, and how I applied for my nephew. The whole process took me a few years, starting from 2016, and he landed in May 2019.


Friday, June 30, 2017

Effective C# 50 Specific Ways to Improve Your C#

June 30, 2017

Plan to read a book:

Effective C# 50 Specific Ways to Improve Your C#


Leetcode 76: Minimum Window Substring

June 30, 2017

Introduction



Leetcode 76 minimum windows substring is such a popular algorithm, Julia was asked to work on the algorithm in mocking experience, the peer likes Julia to work on the string algorithm, and the peer gave the advice that Julia's solution will have time out issue.

Algorithm study 



Mocking 8:00 pm - 8:30 pm

Here is the C# practice in mocking experience, the code has timeout issue. Time complexity should be cut down.

Here is the C# practice to pass online judge of Leetcode 76.

Leetcode Discussion


Read one of discussions - link is here.

Need to write a short and better solution.

The current window is s[i:j] and the result window is s[I:J]. In need[c] I store how many times I need character c (can be negative) and missing tells how many characters are still missing. In the loop, first add the new character to the window. Then, if nothing is missing, remove as much as possible from the window start and then update the result.

Julia is very good at writing the code, she just need a good idea to work on.

C# code is rewritten, link is here.

What can I say after I debug the code using a test case? This code is hard to understand, one dictionary serves multiple purposes. It reminds me the algebra.

For example, "xxyz", search string is "xyz".
We can keep the search string in the dictionary<char, int>
dict['x'] = 1,
dict['y'] = 1,
dict['z'] = 1

Now, we like to use those values to track how many in the sliding window. If the sliding window is "xx", then dict['x'] = -1. If the value is 0, then the number of char is exactly what need. -1 means that there is extra one.

We also keep count of how many chars we need in search string. First visit of x in sliding window "xx" we increment count variable once, but second one we do not do that. In other words, there is only one 'x' in search string. From any iteration, it is easy to tell if the sliding window contains the search string by comparing count variable with the length of search string.

Queue is not necessary, just track the left position of sliding window. One advantage to use queue is to filter out characters not in the search string.

Move Queue from the code, and come back to work on the algorithm later.

Most important is to check time complexity of this idea, it is better than O(s.Length * t.Length), actually it is O(s.Length).

C# SortedSet talk

June 30, 2017

It is a great idea to learn C# programming language using Leetcode. Julia searches Google using keyword "C# SortedSet Leetcode", and then she finds the following algorithms to work on:

Leetcode  23  Merge K Sorted Lists
Leetcode  57  Insert Intervals
Leetcode 128 Longest Consecutive Sequence
Leetcode 220 Remove Duplicate III
Leetcode 239 Sliding Window Maximum
Leetcode 295 Median of Streams


It takes a few hours to study those algorithm written using C# SortedSet.

Leetcode 295: Median of Stream

June 30, 2017

Work on the C# code using SortedSet. Here is C# practice.

Review book: Effective C# 50 Specific Ways to Improve your C#, Item 31: Implement ordering relations with ICompare<T> and IComparer<T>


Leetcode 23: Merge K Sorted Lists

June 30, 2017

Julia tried to learn more about C# SortedSet, so she googled "C# SortedSet Leetcode" first, and worked on a few algorithms implemented using SortedSet.

C# practice is here.


Leetcode 220: Remove Duplicate III

June 30, 2017

C# practice is here.

Leetcode 239: Sliding Window Maximum

June 30, 2017


Julia is learning C# SortedSet, so she chose the algorithm to practice SortedSet. C# practice is here.

Leetcode 57: Insert intervals

June 30, 2017


Julia likes to learn to use C# SortedSet, and then the algorithm can be implemented using the class. C# code is here.

Leetcode 128: Longest Consecutive Sequence

June 30, 2017

It is a great idea to learn C# SortedSet by looking up Leetcode algorithms, search Google using keyword: "C# SortedSet Leetcode". Here is the C# practice code.


Wednesday, June 28, 2017

Common mistakes talk

June 28, 2017

Introduction


It is a good idea to celebrate 80 times mocking experience with a coding blog. What is the good topic? Julia learned a lot, and she likes to write common mistakes in the mocking experience.

Julia did some research on the topic "Do mocking make difference?". Julia likes to set a new goal for her practice, improve her communication.

One interesting topic Julia likes to bring up is 3000 algorithm practice, Julia likes to build up skills by playing hackerrank contest, Leetcode practice and mocking experience. And also Julia learns to journal her emotions through the practice in order to build mental toughness.

Julia started to cut short those long hours for Hackerrank contest, she likes to write a few blogs when she prepares to solve a medium or expert level algorithm, she also likes to read some good lecture notes and do some research on the topic, certainly Julia learns to succeed on week code of 33 and enjoyed her first gold medal.


Common mistakes 


Julia was complained once that she made the mocking experience like an exam, it should be a conversation. And another time Julia was told that if she was given a hint, she should take it, do not be a hacker. Julia learns to respect the peer and follow the direction right away. So she was surprised that today mocking experience, she tried to give same advice, but the peer did not take it. 

Here are 10 more mistakes Julia learns from her last 80 mocking experience:

1. One of the peers asked very politely in the first minute, how does the mocking work? Are you a professional?  Question is how to show up very professionally? Age difference?
2. Prepare peer's algorithm very well as an interviewer. For example, quickly look up Google and get  an API stackoverflow link for the peer.
3. Miss base cases in the algorithm analysis
4. Do not talk and explain the base case in DFS design in the first place. Need to learn more about DFS algorithm design, know different kinds of solutions, and then communicate efficiently.
5. Easy to get stuck or be distracted from the algorithm.
6. Fail to come out dynamic solution or recurrence formula quickly. Julia did notice the issue in her first round.
7. Some of peers expect the code ready to run with test cases and you should show the correct result.
Work hard until you can write the algorithm and make sure that the algorithm can run. Practice more.
The third time Julia wrote the same algorithm and then she was asked to run the code, she had a few bugs to fix.
8. Do not write code until you have fully figured out the algorithm. Explain the algorithm and share your thinking process. Julia had the mistake in one of her first 20 mocking practice.
9. Learn whiteboard testing. But test the code very hard. Do not fake it. Julia still found bugs by running the code using sample test case, after whiteboard testing. Do not fake the testing, work hard.
10. Prepare to extend the algorithm if the peer finish only first 10 minutes, try to extend the algorithm until the peer fails. Know how to measure the depth of the knowledge. Julia figured out after practicing more than 80 mocking practices.
11. Miss the optimal solution for an algorithm after more than 3 times practices. Julia knew the issue after 90 mocking practice.
12. There are always something new coming out in each mocking experience. Julia noticed that after she started third round.


Related work from Hackerrank contest 




Julia likes to play tennis sports and play hackerrank contests. Both needs hard work.

Julia played over hundreds of hours tennis sports, hundreds of double and single matches, experienced the muscle pain and all kinds of issues, she also experienced a lot of joy through the hard work. She learns to control the ball and placement so well over thousands of strokes, she gains the new sports skills.

Related to tennis sports, from June 2016 to June 2017, Julia built up similar experience through Hackerrank contests, she journal every practice, wrote down her emotion, time to play, short term and long term goal, she started to collect 7 bronze medal, 2 silver medals, one gold medal last 12 months. Exactly after 12 month, she got her first gold medal, top 4% in ranking of over 11,000 players. She adapted her skills on tennis sports to competitive programming field. 

Julia plays so many contests, there is always next one. No time to get frustrated long because she has to play next one and stay at the moment. It is hard to deal with frustration and expectation, but Julia learns to take care of herself with a lot of sports competition matches, just remind her that hard work beats the talent. Wishful thinking wastes time, but choose to sports therapy, learn from tennis professional players to work on basics. 

Learn to count algorithms


It is not easy to stay humble for computer science Ph.D. students. Julia worked on the computer science Ph.D. study from 2001 to 2010, she never learned to count how many algorithms she works on. There is no target, no goal setting on algorithm practice, and there is no result.

How does Julia happen to make changes after her full time work last 7 years? Julia learned the tough lesson when she developed the sales analysis report. She was challenged again and again about the number she provided, she did not handle the pressure very well the first few years. From 2010 to 2015, Julia does not count how many algorithms she works on.

Starting from 2015, she put months hard work together to rewrite C# code with the new design, she likes to integrate with Microsoft Excel easily so she can continuously build some analysis.

One day she sets a goal, she likes to be able to verify the final number in less than five minutes; she added the drill-down functionality in her report, she can quickly export large data sets and use Microsoft Excel to do further analysis to find root cause if need.

Be a top player in algorithm and data structure contest on hackerrank, Julia also sets up a goal.

Her goal is to complete 3000 algorithm practice, enjoy the journey; she works on leetcode, meanwhile playing hackerrank contest; when she plays hackerrank contest, she uses Leetcode algorithms to help her to be a better player. She only completes over 100 algorithm related to Leetcode algorithm. Her gists shows 851 gists on June 29, 2017. 

C# Minimum Heap implementation

June 28, 2017

Introduction


There is a PriorityQueue class in Java for minimum heap, but in csharp programming language, there is no class. Julia has to figure out how to write one by herself.

Search the blog using minimum heap implementation, the link is here.

Algorithm study 


8:00 pm - 8:30 pm C# practice is here.

Julia met a peer who is a computer science Ph.D., and she was asked to simulate the minimum heap using Array, Array.Sort. Julia followed the hint and she did write one. It works and the solution is correct. But she likes to make her simulation better. There is only 30 minutes in mocking experience, Julia could not write a real minimum heap so she chose to use an array and then sort it using O(nlogn) algorithm.

She needs to look into C# books and figure out how to do it better in short future.

One of ideas is to use C# SortedSet class. Review previous practice on Leetcode 295: Median of stream.


Book reading: Essential C# 4.0

June 28, 2017

Introduction



It is the seventh year Julia works on C# programming on the current job in the city of Vancouver. Last 2 years Julia tried so hard to reinvent herself, she chose to work on Leetcode, coding blog, and focus on the basics.

Julia knows that it is so enjoyable to read a C# book in her spare time, she did today using 20 minutes, on the topic called "16 Building Custom Collections".

Book reading plan 


Actionable Item

Next book to read:
Effective C# 50 Specific Ways to Improve Your C#
Second Edition Scott Meyers

Book review is here.

Algorithm design talk

June 28, 2017

Introduction


It is very interesting to learn different issues to learn binary search algorithm. Most popular algorithm is a binary search algorithm. When is your last time to write a binary search algorithm?

In last 6 months, Julia wrote at least 5 times binary search algorithms, she had at least 5 peers to work on binary search algorithm. She knows so many ways to create bugs in binary search algorithm, but today's mocking experience the bug is new, the series are not convergent at all.

Binary search algorithm


It is a long journey to work on binary search tree algorithm in 2017. Julia struggled over a few hours on binary search tree algorithm in one of Hackerrank contest, she could not figure out why she failed on an issue and could not make significant improvement even after the contest.

Julia did over 80 mocking experience since March 2017. One thing she learned most is the binary search algorithm. She wrote a few times and also she watched how peers worked on binary search tree algorithm. It is most favorite algorithm Julia likes to practice again and again.

One thing Julia was so surprised is the design the peer gave out in binary search algorithm which cannot be convergent. (Mathematics series –convergent)

Mocking experience


Julia regularly attended the church but she never practiced algorithm and data structure with a peer from 2010 to 2015. Those five years Julia learned a lot through small group church activities.

Julia used to have one real experience in 2015 and then she did not have any mocking experience. In 2016 Julia only did 8 mocking experience and then she moved on. In 2017 March, Julia started to try to practice mocking, and then she did very well last few months.


As a hackerrank player, Julia can relate mocking experience learning to contest playing. At the very beginning, Julia studied a lot of hackerrank players through leaderboard and blogs they share, code in submissions. Until November 2016, Julia was lucky to start to get involved with code review community and learned a lot through asking questions. She asked help on code review and then she learned to solve hackerrank contest problems better and more understanding. 

Now Julia had 80 mocking experience since March 2017, she met so many peers and then she starts to look into possible topic for her short research. What Julia likes most in the algorithm problem solving?



Tuesday, June 27, 2017

Inorder successor binary search tree

June 27, 2017

Introduction


It is time to work on a few solutions on this binary search tree inorder successor. A simple idea is to go over the leetcode discussion on the algorithm, and study a few solutions.


Algorithm practice


May 20, 2017 C# practice is here. 
June 27, 2017 8:00 pm - 8:30 pm, 30 minutes practice is here.

The C# practice with test cases is here. More simple code is here.

July 4, 2017
Work on the solution without using parent node pointer.



Monday, June 26, 2017

Leetcode weekly contest 38

June 26, 2017

Introduction


It is a good idea for the summer day. Get up early one week day morning, like 6:00 am or 7:00 am, work on one Leetcode weekly contest and get some morning workout.

Here is the link of Leetcode weekly contest 38.

Algorithm practice 

N-th root of a number

June 26, 2017

Introduction 


Plan to work on N-th root of a number on geeksforgeeks.com.

Algorithm practice 



May 3, practice is here. 

May 30, C# practice is here. Root a number by power of n, for example, 0.001 - n = 3, root number is 0.1. 

June 26, C# practice is here. 

Julia did white boarding test on her own code, and then she found a bug on line 29 on test case 0.001, n = 3, search value 0.1. Julia tested her own code very carefully, and then find a bug on line 29. The peer asked the question to point out the bug on line 75, return integerValue/ 1000.0; not integerValue/ 1.0. At the end, there is a dead loop, so Julia put some debug code and traced down the bug on line 74, type conversion bug. 



Sunday, June 25, 2017

Weight control project

June 25, 2017

Introduction



Summer is here in the city of Vancouver. One of goals in the summer is to play more sports, and also learn new skills to apply weight control.

Julia is busy working with hackerrank contests last 6 months, she also found out that she missed a lot of hours on tennis court. She used to spend a lot of summer time hours on tennis courts, play a lot of double matches, long hours to stay outdoor.

Weight control study 


Study BMI index again. Link is here. Plan to reduce the weight and get back to overweight, say goodbye to obesity weight. 




3000 algorithm practice

June 25, 2017

Introduction



It is estimated that a good software programmer should practice at least 3000 easy and medium algorithm based on her research on competitive programming. Right now, Julia had around 800 algorithm in her gist profile. It takes a while Julia adopts the idea called one algorithm a time based on her research on tennis coaching and mental strategies study. Never rush herself to finish algorithms. She used to study 10 algorithms in 3 hours, or 30 algorithms in one week, or tried to go over 70 algorithms in 3 or 4 hours.

It is better to learn one algorithm a time. Based on her study of the book "The art of competition programming", the book chapter the game plan of contest, Julia learned that it is also very helpful for her to go over each algorithm as many as possible ideas based on Leetcode discussion. She also learned that it is also very helpful to solve an expert level algorithm, in order to find a solution, Julia will quickly build up skills to do some research on algorithm, review the basics, and tries a few ideas.

Small research talk 



Read the blog again, link is here. Read the article again called "Competitive programming is a good use of time".

Review 3 advanced topics for competitive programming:

1. Fenwick tree
2. Max flow algorithm
3. Bitmask DP

Try to answer a few questions on Fenwick tree - binary index tree

One discussion on binary index tree is here on cs.stackexchange.com.

Second discussion on Fenwick tree is here on cs.stackexchange.com.

Study Hackerrank ProjectEuler+ leaderboard - link is here.

Codefights.com study

June 25, 2017

Plan to spend 30 minutes to study codefights.com website.

Friday, June 23, 2017

Game plan for a contest

June 23, 3017

Introduction


It is most enjoyable time to read a book chapter called "Game Plan for a contest", one chapter from book "The Art of Programming Contest".



Book chapter: Game Plan For a contest 



Julia likes to memorize classical problems for each classical algorithm. Here is the set of problems.





ACM ICPC world final problems - link is here. 

Leetcode 140: Word Break II

June 23, 2017

Introduction


Problem statement 


Plan to work on word break II algorithm sometime in short future.


Julia worked on Leetcode 139: Word Break I before, here is the blog.

Leetcode 55: Jump Game I

June 23, 2017

Introduction




Julia worked on the algorithm in 2015. Here is her C# practice.

Leetcode 45: Jump Game II

June 23, 2017

Introduction


It is one of hard level algorithm. The problem statement is here.

Julia worked on the algorithm in 2015. Here is her C# practice.


Algorithm 


Julia spent over 30 minutes to study one of greedy solution posted in the discussion, and then C# practice is here using greedy algorithm. 

Wednesday, June 21, 2017

Leetcode 72: Edit Distance

June 21, 2017

Introduction



Plan to work on Leetcode 72: Edit Distance again. The problem statement is here.

Algorithm study 



Julia's C# practice is here. 

Follow up

Dec. 10, 2019 10:49 PM

It is better to add code to the blog. Also I spent 10 minutes to review the code, there are three cases involved to build next iteration in dynamic programming, left, top, and left and top, first two the increment is 1, last one may be one or zero, depending on last char in two strings are the same or not.

This definitely is a good practice question for dynamic programming.

Tuesday, June 20, 2017

Can mock interview make difference? Continued II

June 20, 2017

Introduction



It is the first time Julia continuously works on mock interview experience starting from March 2017. Now she starts to understand the process better, and she starts to learn more things from the activities.

"It takes a village to raise a child". Julia knows that she could not do something alone and one day she is expert on algorithm and data structure. It is the great learning experience to work on the same algorithm together with a peer and learn from each other. 

Recently a computer science undergraduate student asked Julia what advice she has, because the peer likes to get more professional interviews from refdash.com. 

Julia learned a few things through the conversation. Julia was told that interviewbit.com is very popular site to practice coding.




Research talk 


Julia had her first professional mock interview experience in May 2017, and she got the comment like the following:

"Pretty solid interview overall. Algorithms and problem comprehension was on a pretty high level. Coding was good as well, but got a bit sloppy at times when we got to details (very minor edge cases)."



Can mock interview make difference? Continued

June 20, 2017


Introduction



"It takes a village to raise a child". Related to improve algorithm and data structure, Julia learned that it also takes the hundred people to help her learn depth first search using recursive function.

As a classical depth first search algorithm, Julia worked on the Sudoku algorithm in 2015, she collected over 10 solutions; She thought that she mastered the sudoku algorithm in 2015, actually not! How did Julia find out the fact?

Julia practised Sudoku solver in April and May of 2017. First experience is in April, the peer complained that Julia forgot to write a base case in her first writing and gave a rating of 3 with comment "Do not know how to write code", and then second one is in May, the peer coached Julia to set base case first thing in the design, do not write any small function, keep it short as possible, quick as possible. From those two hours to work with two different people, Julia learned to stay humble, learn and quickly fix her learning issues. With those two mock interview experience, Julia learned the Sudoku solver in totally surprising ways. Learn from people from recent graduate and senior developer, recent graduate explained what to work on through Google onsite experience, and the senior developer showed her later in second meeting with more tips.

June 18 and 19 weekend, Julia worked on the expert level algorithm called path matching, she scored 0.46 out of maximum score 100, she worked on over 5 hours but she learned depth first search again through the problem solving. Julia likes to solve the problem first, it does not matter if she scored less than 0.5%. She likes to get expert level algorithm problem solved first.

Julia starts to meet a person a day to work on algorithm problem solving, she also pays attention to peer's curiosity level on algorithm and problem solving, how good the peer can influence her through one hour conversation. Today she was surprised that the peer shared her link to solve C# problem from stackoverflow.com. Also the peer also typed the test case for her, and then Julia found out that her code had a bug, wrong output.

Julia learns how to do whiteboard testing and she did one today as well. But she missed the bug. So she felt that the peer is much better a tester and maybe she is a project manager working somewhere. It is the second time Julia worked on the algorithm.

A research talk 



The mocking experience is short, only one hour, the peer chose to turn off the video. But the quality of the work is very impressing, Julia found out that she is lacking of this kind of preparation for the mocking experience. 

Julia worked on extra 10 minutes to use Microsoft visual studio to find the bug. It is an excellent experience. 

C# code is here. 

In the line of 44, the new variable should be declared for each key value pair of dictionary. It is called nextPrefix. Do not change the function argument prefix, based on the least astonishment principle.

So share the advice Julia got today.

-very good communication, i liked how you explained your thought process thoroughly -got to the answer fast but still made sure to test before writing code

it's ok to ask the interviewer if you can look up inbuilt/library functions for the language if you need to, that might be helpful sometimes.


Can Leetcode weekly contest make difference?

June 20, 2017

Introduction



It is a ritual to do small research every day. Today Julia chooses a topic called "Can Leetcode weekly contest make difference?"

The reason Julia chose the topic is that she found out her last leetcode weekly contest reminded her to work on the basics - linear scan array more efficiently. The blog is called Leetcode 605: Can place flowers.  Julia found a very short solution through Leetcode discussion after she spent 48 minutes in the contest, she learned to solve the problem using 5 minutes. Only 10% of time, she learned the basics of linear scan an array, looping first.

On June 19, Julia noticed that she performed better on mocking experience of algorithm Leetcode 151 compared to her last one more than one month ago.

The argument is that "Leetcode weekly contest makes difference".


Performance talk 


Leetcode.com is so helpful because it attracts million players to share ideas, compared to code review on stackexchange.com, Julia found out that Leetcode.com is a good place to find excellent ideas to solve a Leetcode algorithm, but codereviwe.stackexchange.com is an excellent place for Julia to practice good writing and learn how to share her learning. 




Monday, June 19, 2017

10 steps to master dynamic programming (step II)

June 19, 2017


Plan to work on interviewbit.com dynamic programming tutorial. Here is the link of dynamic programming algorithms.


First Gold Medal on Hackerrank

June 19, 2017

It is time to celebrate first gold medal on Hackerrank. Julia won her first gold medal on hackerrank, she played week of code 33, and then she worked hard and then she was in top 4% ranking.

Here is the image she likes to show the medal to celebrate. It is not easy, after more than 12 months, she finally made it happen.


Here is julia's hackerrank profile link.

Julia likes to play hackerrank contest, and also she works hard on basics through Leetcode algorithm practice.

Here are the contests she attended and she likes the failure and also likes the progress to gain skills to perform better. It took her six months to get her first gold medal in 2017.


She still remembered in April she played this contest called world codesprint 10, she documented that the huge difference between top 10 players and Julia's performance. The blog link is here.

In April, Julia set a goal for a gold medal. Here is the blog called "Talent small talk".

Psalm 126: 5 Those who sow with tears will reap with songs of joy.

Sunday, June 18, 2017

Leetcode 76: Minimum Windows Substring

June 18, 2017

Problem Statement

First step Julia spent over 60 minutes to write and then failed several times, she finally passed first 267 test cases, and last test case failed with timeout error. C# code is here.

A lot of failed test case in her practice:

1. A lot of out-of-boundary index error, "abc", "a"
line 57 and 58, search[left] - make sure that left is in the boundary of the array

2. "a", "aa", need to check counts as well.

Knight Covering - codeChef

June 18, 2017

Introduction



It is very good learning experience to play contest on codeChef. Julia is a rookie to play short contest, 2.5 hours. She started to choose to read chinese version of problem statement, here is the problem statement.

She also did some google search, and found the similar algorithm, N x N board instead. She spent 10 minutes to read the algorithm. Link is here.

Saturday, June 17, 2017

Leetcode: Number of Connected Components in an Undirected Graph

June 17, 2017

Introduction



Julia has to work hard on expert level algorithm, she plans to work on the algorithm called "Path Matching" in the week of code 33. Julia needs to find some topics to study in order to come out a working idea to solve partial the algorithm.

One of her studies is about network, n nodes with n - 1 edges, what implies to this graph? Julia likes to find path for any two nodes. What should be included for a good consideration before she comes out the idea to search a pattern.

Algorithm study


Read the blog written by Grandyang, the blog link is here.

Leetcode: Number of Islands II

June 17, 2017



Introduction




Julia has to work hard on expert level algorithm, she plans to work on the algorithm called "Path Matching" in the week of code 33. Julia needs to find some topics to study in order to come out a working idea to solve partial the algorithm.

One of her studies is about network, n nodes with n - 1 edges, what implies to this graph? Julia likes to find path for any two nodes. What should be included for a good consideration before she comes out the idea to search a pattern.



Algorithm study


Plan to read a blog written by jcliBlogger, the link is here. 

Leetcode number of islands II, the link is here. 



Leetcode: Graph Valid Tree

June 17, 2017


Introduction


Julia has to work hard on expert level algorithm, she plans to work on the algorithm called "Path Matching" in the week of code 33. Julia needs to find some topics to study in order to come out a working idea to solve partial the algorithm.

One of her studies is about network, n nodes with n - 1 edges, what implies to this graph? Julia likes to find path for any two nodes. What should be included for a good consideration before she comes out the idea to search a pattern.

Algorithm study 


One blog written in Chinese called grandyang is here.  It is now 9:15pm, Julia likes to go over the algorithm 15 minutes before she moves on to the Leetcode discussion session for broad discussion. 

Plan to study the code in the blog, and write a C# version. UnionFind using array is very good practice. 


Hidden message algorithm code review

June 17, 2017

Introduction



The algorithm "hidden message" is the medium algorithm in stryker contest in 2016. Julia decided to review the algorithm based on her blog since she likes to get more idea on how a trie data structure to solve the string search algorithm very well. Recently Julia noticed that she could not figure out using trie to solve a timeout issue on Leetcode algorithm 212 Word Search, she knows that her training has some issues, she needs to emphasis more on trie. 


Algorithm code review 



The C# code is here to review.

Leetcode 572: subtree of another tree

June 17, 2017

It is time to review one of blogs written for the algorithm. The blog link is here.

Leetcode 459: repeated substring patterns

June 17, 2017

Problem statement


Leetcode 44: wildcard matching

June 17, 2017

Problem statement

It is hard level algorithm. Julia tried the algorithm a few times in mocking experience, she used the algorithm a few time to interview and also was interviewed.

Now it is 9:36 am, Julia likes to read some discussion. Plan to spend 20 - 30 minutes.

First, Julia was advised in mocking experience to use recursive function to make the code more easy to write.

Special test cases are looked into:

1. ?*, any character repeated multiple time, ? represents any character, * means repeating multiple times.

2. If string is finished, but the pattern string is not, it is still possible to match. Pattern string ?*, a* or a*b* etc.

3. Some challenging matching, like "aaa" to match "a*a", how to wisely calculate a* pattern to match first two chars instead of all three characters.

Study code using DP solution - link is here.

Path Matching - week of code 33

June 17, 2017

Problem statement


Research and study plan 


It is the expert level algorithm. As a hackerrank player, Julia is still learning how to solve the expert level algorithm partially. What she likes to do is to dedicate a few hours, think about ideas, study related topic, and most important is to go over related algorithms in Leetcode, topcoder, hackerearth, and read some lecture notes.

After a few hours study, Julia starts to come out some idea to solve basic sample test cases first, leave timeout and performance issues as is until she comes out the great idea to solve the issue.

1. Leetcode 44 - wildcard matching - 20 - 30 minutes research and study, documented in the blog:
wildcard matching.

2. Review string search algorithm KMP, Rabin algorithm on topcoder. Link is here.

3. Review KMP and other string search algorithm on Julia's coding blog as well. Now it is 10:11am.

4. Review "the hidden message" algorithm on hackerrank contest. The blog is here.

5. Leetcode: Graph Valid Tree - the coding blog of grandyang is here.

Time is 9:07 pm, June 17, 2017
It is hard to figure out the idea to solve the path between two nodes. Julia likes to study some good algorithm.

She googled n nodes n - 1 edges meaning - no cycle in the graph, a tree?

6. Read lecture notes about union find data structure - lecture notes by Princeton is here. Now it is 9:55 pm.

Follow up after the contest


The code submitted in the contest is here. Score 0.47 out of maximum score 100.

Plan to study the Java code written by Salmur - score 100, link is here.

Plan to study the discussion provided by one of players. Link is here.