May 31, 2017

Study leetcode 416: partition equal subset sum. The problem link is here.

Amazonian - USC alumni - Xie Tao - Leetcode profile is here.

Study the solution:

Java dynamic programming solution is here.

Julia's C# first practice is here.

## Wednesday, May 31, 2017

### Leetcode 295 Median of stream

May 31, 2017

Leetcode 295. Find median from data stream - discussion panel is here.

C# solution using SortedSet. The C# code to study is here.

C# solution using MinHeap/ MaxHeap - self defined. The study code is here.

Read blog about the discussion again - link is here - the blog on ardendertat.com

June 6, 2017

Julia C# practice using SortedSet, the code is here.

Julia C# practice using self-defined Heap, the code is here.

June 29, 2017

Review SortedSet implementation, the code is here.

Leetcode 295. Find median from data stream - discussion panel is here.

C# solution using SortedSet. The C# code to study is here.

C# solution using MinHeap/ MaxHeap - self defined. The study code is here.

Read blog about the discussion again - link is here - the blog on ardendertat.com

**: Median of a stream (Julia's ranking: 10 out of 10 March 31, 2017), book: Code interviews, Harry He.***Question 69*### Follow up

June 6, 2017

Julia C# practice using SortedSet, the code is here.

Julia C# practice using self-defined Heap, the code is here.

June 29, 2017

Review SortedSet implementation, the code is here.

### Actionable Items

Google search "SortedSet C# example leetcode", work on related algorithm, try to get more practice on SortedSet.## Tuesday, May 30, 2017

### Leetcode 69. Sqrt(x)

May 30, 2017

Plan to review Leetcode 69. Sqrt(x).

Blogs to study, yocoding blog is here.

codganker blog is here.

C# implementation:

Leetcode 69 C# 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. Learn to test your own code very carefully, and then find a bug on line 29. But Julia missed the bug on line 74. The peer asked the question to point out the bug on line 75, return integerValue/ 1000.0; not integerValue/ 1.0.

Plan to review Leetcode 69. Sqrt(x).

### Past practice

69 sqrt(x)Blogs to study, yocoding blog is here.

codganker blog is here.

C# implementation:

Leetcode 69 C# practice is here.

### Mocking 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. Learn to test your own code very carefully, and then find a bug on line 29. But Julia missed the bug on line 74. The peer asked the question to point out the bug on line 75, return integerValue/ 1000.0; not integerValue/ 1.0.

### Pluralsight: Preparing for a job interview

May 30, 2017

Plan to spend 2 hours to study the course. Julia is doing a research for fun, her research topic is how to be a professional interviewer.

John Sonmez - linkin profile is here.

Algorithm based questions - 34 minutes

Plan to spend 2 hours to study the course. Julia is doing a research for fun, her research topic is how to be a professional interviewer.

John Sonmez - linkin profile is here.

Algorithm based questions - 34 minutes

### How to be a professional algorithm interviewer?

May 30, 2017

It is a natural question to ask yourself how to be a professional algorithm and data structure interviewer/ interviewee. After practicing mocking more than 40 times, Julia starts to think about this small research topic. This is the first time she experienced so many mocking experience, and then she asks herself what is motivation to continue, what she learns, what surprises her, what she likes most.

Julia has the chance to know the company refdash and also experienced once how a professional interviewer perform the mocking experience. A professional algorithm interviewer will meet over 1000 people through mocking experience in less than one year.

Things to learn:

1. Take mocking notes - time, what question ask/ being asked?

2. Prepare hints

3. Learn to have a quick code review - find bugs, sort priorities

4. Learn to rate the peer using 1 - 4, understand 2.5 passing bar.

5. Know 3 things to interview, knowledge, analysis, execution.

Advice:

A - Ask correct questions

C - Comprehend the problem

L - Listen carefully

M - Find multiple solution, choose optimal one

O - open to new idea, inventive and flexible

U - move up to more complex algorithm

1. UVA career center - article is here.

2. Havard junior talked about interview and how to structure the interview. The article is here.

4. Quora question - the link is here.

5. Interview Kickstart - quora link is here.

June 6, 2017

Hiring Series - blogs written by jocelyn goldfein. Link is here.

### Introduction

Julia has the chance to know the company refdash and also experienced once how a professional interviewer perform the mocking experience. A professional algorithm interviewer will meet over 1000 people through mocking experience in less than one year.

### A small research

The research topic is for fun and also bring into some good thoughts later.

Google and find one article about what Google to look for:

"We are not simply looking for engineers to solve the problems they already know the answers to;
we are interested in engineers who can work out the answers to questions they had not come
across before."

Interviewers will be looking at the approach to questions as much as the answer:

* Does the candidate listen carefully and comprehend the question?

* Are the correct questions asked before proceeding? (important!)

* Is brute force used to solve a problem? (not good!)

* Are things assumed without first checking? (not good!)

* Are hints heard and heeded?

* Is the candidate slow to comprehend / solve problems? (not good!)

* Does the candidate enjoy finding multiple solutions before choosing the best one?

* Are new ideas and methods of tackling a problem sought?

* Is the candidate inventive and flexible in their solutions and open to new ideas?

* Can questioning move up to more complex problem solving?

Google is keen to see really high quality, efficient, clear code without typing mistakes. Because all
engineers (at every level) collaborate throughout the Google code base, with an efficient code
review process, it’s essential that every engineer works at the same high standard.

Things to learn:

1. Take mocking notes - time, what question ask/ being asked?

2. Prepare hints

3. Learn to have a quick code review - find bugs, sort priorities

4. Learn to rate the peer using 1 - 4, understand 2.5 passing bar.

5. Know 3 things to interview, knowledge, analysis, execution.

Advice:

A - Ask correct questions

C - Comprehend the problem

L - Listen carefully

M - Find multiple solution, choose optimal one

O - open to new idea, inventive and flexible

U - move up to more complex algorithm

### Study Refdash/ Interview Kickstart

1. UVA career center - article is here.

2. Havard junior talked about interview and how to structure the interview. The article is here.

- Repeat the question to make sure that you understand it and have all the relevant details.
- Clarify the function input and output.
- Check assumptions.
- Give an approach to solving the problem.
- Discuss the tradeoffs of the approach.
- Code the solution.
- Test the solution with a normal test case.
- Test the solution with some edge cases.

4. Quora question - the link is here.

5. Interview Kickstart - quora link is here.

June 6, 2017

Hiring Series - blogs written by jocelyn goldfein. Link is here.

## Monday, May 29, 2017

### Second silver medal on hackerrank

May 29, 2017

It is a nice and long journey for Julia to win a silver medal on world codesprint 11. Julia spent over hours to work on first 5 algorithms and she enjoyed the contest. Now it is 11:20 pm, Julia chose her tonight study topic is about "

Here are some facts:

1. Need more hours to work on the expert level algorithms

2. Do not plan very well. Instead of staying up to 3 am, Julia should go to bed early and work from 6 am - 9 am. Early morning hours is blessing used for work.

Bible verse shares the secret to get up early and work hard.

Read the article "6 Reasons Why Staying Up Late Can Be Toxic for Your Health", things to consider with negative influence: bad eating habits, not enough sleep, immune system to get weak, melatonin production can be affected, prone to negative thoughts & anxiety, risk for sleep disorders, a bad habit & insomnia.

3. Need to work on long term, work on expert level algorithm. Take 30 minutes a time for each expert level algorithm. Take some risk not to score anything.

### Introduction

**". She did one study on a top player who scored 189, almost double score Julia made (90), also the player won a silver medal.***How to play smart on Hackerrank contest?*Here are some facts:

1. Need more hours to work on the expert level algorithms

2. Do not plan very well. Instead of staying up to 3 am, Julia should go to bed early and work from 6 am - 9 am. Early morning hours is blessing used for work.

Bible verse shares the secret to get up early and work hard.

Read the article "6 Reasons Why Staying Up Late Can Be Toxic for Your Health", things to consider with negative influence: bad eating habits, not enough sleep, immune system to get weak, melatonin production can be affected, prone to negative thoughts & anxiety, risk for sleep disorders, a bad habit & insomnia.

3. Need to work on long term, work on expert level algorithm. Take 30 minutes a time for each expert level algorithm. Take some risk not to score anything.

### Silver medal talk

### Clean code: Writing code for Humans

May 29, 2017

Study the code on pluralsight.com. The course is called "Clean code: Writing code for Humans".

Read the article on pluralsight.com. "

Take some notes here.

11:13 pm, 5/29/2017

The course is released on Oct. 7, 2013. It is always on time!

Julia, it is always better to learn coding styles, principles first and then practice leetcode algorithms.

Cory House - the lecturer of the course's website is here.

assign booleans implicitly (Julia's favorite rating: 7 out of 10)

- 3 good reasons to create a function (10 out of 10)

convey intent, eliminate excessive indentation, avoid duplication

problem with zombie code

Boundaries matter - (Julia's rating: 9 out of 10)

dynamic JS in C# (JavaScript and C# etc),

html in JS string,

JS in HTML (JavaScript and Html),

inline Styles (css and html),

Dynamic SQL in C# strings

Stay native - advantages (Julia's favorite ranking 9 out of 10)

1. Cached

2. Code colored

3. Syntax checked

4. Separation of concerns

5. Reusable

6. Avoids string parsing

7. Can minify & obfuscate

Maximize signal to noise ratio (Excellent concept!)

Signal

Logic that follows the TED rules:

Terse

Expressive

Do one thing

Noise

High cyclomatic complexity

Excessive indentation

zombie code

unnecessary comments

poorly named structures

huge classes

long methods

repetition

no white space

overly verbose

Self-documenting code

Well written code is self-documenting.

Clear intent

Layers of abstractions

Format for readability

Favor code over comments

Complex conditionals

Discussion topic - excessive indentation: solutions

extract method

fail fast

return early

Mayfly variable - just in time

June 5, 2017 11:00 pm - 11:53 pm

Demo 42 minutes

Bug Fix: What a contrast (

Terse

Expressive

Do One Thing

Watch the lecture titled "Clean Code"

July 29, 2017 10:30 pm - 11:30 pm

Go over the lecture video again

Terse, expressive, do one thing

Don't repeat yourself

How to write

clear intent

layers of abstraction

Study the code on pluralsight.com. The course is called "Clean code: Writing code for Humans".

Read the article on pluralsight.com. "

**" article is here to read.***7 reasons clean code matters*Take some notes here.

11:13 pm, 5/29/2017

The course is released on Oct. 7, 2013. It is always on time!

Julia, it is always better to learn coding styles, principles first and then practice leetcode algorithms.

Cory House - the lecturer of the course's website is here.

assign booleans implicitly (Julia's favorite rating: 7 out of 10)

- 3 good reasons to create a function (10 out of 10)

convey intent, eliminate excessive indentation, avoid duplication

problem with zombie code

Boundaries matter - (Julia's rating: 9 out of 10)

dynamic JS in C# (JavaScript and C# etc),

html in JS string,

JS in HTML (JavaScript and Html),

inline Styles (css and html),

Dynamic SQL in C# strings

Stay native - advantages (Julia's favorite ranking 9 out of 10)

1. Cached

2. Code colored

3. Syntax checked

4. Separation of concerns

5. Reusable

6. Avoids string parsing

7. Can minify & obfuscate

Maximize signal to noise ratio (Excellent concept!)

Signal

Logic that follows the TED rules:

Terse

Expressive

Do one thing

Noise

High cyclomatic complexity

Excessive indentation

zombie code

unnecessary comments

poorly named structures

huge classes

long methods

repetition

no white space

overly verbose

Self-documenting code

Well written code is self-documenting.

Clear intent

Layers of abstractions

Format for readability

Favor code over comments

Complex conditionals

Discussion topic - excessive indentation: solutions

extract method

fail fast

return early

Mayfly variable - just in time

### Continue

June 5, 2017 11:00 pm - 11:53 pm

Demo 42 minutes

Bug Fix: What a contrast (

**Julia's rating: 10 out of 10**)Terse

Expressive

Do One Thing

Watch the lecture titled "Clean Code"

### Follow up

July 29, 2017 10:30 pm - 11:30 pm

Go over the lecture video again

**TED Principle**Terse, expressive, do one thing

Don't repeat yourself

How to write

**Self-document code**?clear intent

layers of abstraction

### Leetcode 18: 4 sum

### Rookie in recursive function design

May 29, 2017

It is the great experience to teach myself how to write a correct recursive function to implement a depth first search algorithm. Julia spent over hours to teach herself, how to track a route in depth first search over one hour.

In order to figure out the issue, Julia wrote a depth first search algorithm using stack to help herself. She compared to the version using stack to the one using recursive function. She found out that the issue she had, she did not need to use memoization, she needed a memo to mark visited node to avoid dead loop.

Use non-recursive depth first search algorithm to help the design. Using an explicit stack, it is much easy to follow. Write pseudo code, figure out base case, the design to avoid dead loop, cycle issue, memoization issue, structure the algorithm first. And then use it as the helper of recursive function design.

Recursive function is short and efficient to implement DFS, but error-prone. It is not straightforward. Practice this way to help yourself.

I should say that memoization is extra, next step. Need to work on basic recursive function boundary check first. One thing is to test the code with the sample test cases, slowly and carefully, mark the test case for each line of code using comment.

To be a good tester all the time. Read your own code and go over it, with test cases. Julia, you got the tip from mocking experience.

### Introduction

In order to figure out the issue, Julia wrote a depth first search algorithm using stack to help herself. She compared to the version using stack to the one using recursive function. She found out that the issue she had, she did not need to use memoization, she needed a memo to mark visited node to avoid dead loop.

### Code practice

C# code with dead loop, stack overflow issue. Mocking code is here.

C# code to write a stack to implement Depth First Search (DFS). Code is here.

C# code to write a recursive function. Code is here.

A cheerful heart is medicine. Smile to my own mistake, next time I will ace the recursive function. Coding is done by a human, crafting takes practice!

### Recursive - HARD TO TELL

**Argument:**

Use non-recursive depth first search algorithm to help the design. Using an explicit stack, it is much easy to follow. Write pseudo code, figure out base case, the design to avoid dead loop, cycle issue, memoization issue, structure the algorithm first. And then use it as the helper of recursive function design.

Recursive function is short and efficient to implement DFS, but error-prone. It is not straightforward. Practice this way to help yourself.

### Use stack to help

### Every mistake is valuable

I should say that memoization is extra, next step. Need to work on basic recursive function boundary check first. One thing is to test the code with the sample test cases, slowly and carefully, mark the test case for each line of code using comment.

To be a good tester all the time. Read your own code and go over it, with test cases. Julia, you got the tip from mocking experience.

## Sunday, May 28, 2017

### Numeric string - world codesprint 11

## Saturday, May 27, 2017

### The best mask - world codesprint 11

May 27, 2017

Problem statement is here.

It is 9:30 pm, Julia worked on the algorithm starting from 7:00 pm, and then after 2 hours 30 minutes, she finally made some progress. Here is the report:

As a hackerrank player, Julia got home 3:00 pm, she spent 45 minutes to write a blog about mocking experience to entertain herself first; She took a nap from 5:00 - 6:00 because she felt tired after working on algorithm "

Julia tried to bring herself to a zone before she starts to code again. And then she studied more about "

One thing Julia likes to do is to check ranking by country: Canada. She likes to compare one of top players, and here is the comparison. The time is running out, Julia like to choose some algorithms to work on in next 3 - 4 hours.

Gave up at 10:37pm. Try to give at least 2 hours to solve "

Julia tried the idea to solve the problem, but her solution scored 11 points. She gave up the effort and will work on it after the contest.

May 28, 2017 1:44 pm

After the contest, post the code submitted in the contest. Score 31 out of maximum score 75. Will look into the correct solution later.

### Introduction

Problem statement is here.

It is 9:30 pm, Julia worked on the algorithm starting from 7:00 pm, and then after 2 hours 30 minutes, she finally made some progress. Here is the report:

### Good food, a blog, one hour nap,

As a hackerrank player, Julia got home 3:00 pm, she spent 45 minutes to write a blog about mocking experience to entertain herself first; She took a nap from 5:00 - 6:00 because she felt tired after working on algorithm "

**"; She entertained herself with a friend with dinner, and talked about her mocking experience and hackerrank contest.***city construction*Julia tried to bring herself to a zone before she starts to code again. And then she studied more about "

**" medium algorithm. She knew that she should be able to write something for the algorithm before 12:00 pm.***city construction*### Compare to a peer

One thing Julia likes to do is to check ranking by country: Canada. She likes to compare one of top players, and here is the comparison. The time is running out, Julia like to choose some algorithms to work on in next 3 - 4 hours.

### Understand hard level

Gave up at 10:37pm. Try to give at least 2 hours to solve "

**". The algorithm is asking***city construction**number of ones in the binary expression of x is minimum*. Julia worked on the problem like "**".***number in the binary expression of x is minimum*Julia tried the idea to solve the problem, but her solution scored 11 points. She gave up the effort and will work on it after the contest.

### Follow up

May 28, 2017 1:44 pm

After the contest, post the code submitted in the contest. Score 31 out of maximum score 75. Will look into the correct solution later.

### A cheerful heart is good medicine

May 27, 2017

Always have a cheerful heart on your own or peer's mistakes, they are the best friends of algorithm problem solvers. Coding is a crafting skills, talk about mistakes, journal the transcript, and then get back to compete again.

People with top talent to attend mock usually are very young and just start his/ her career, and one time Julia felt that the hints were too strong in the first 5 minutes, she had to take the hint given by peer. The algorithm is 4 sum, Leetcode 18. Second time she was mocked again using similar algorithm like 4 sum, she decided to work on practice Leetcode 4 sum. Here is her practice C# code. Her second mock code is here.

Julia learned so many lessons from her own mistakes. She could not figure out dynamic programming

Julia wrote a bug on spiral matrix first as an interviewee, and then she interviewed some one the spiral matrix. She observed carefully the peer's performance, she had more confident to make the code perfect later on.

Every peer get stumbles in mock experience, she reminds herself not long ago she had same experience. Julia felt so connected through mock experience.

She suddenly found out that she never met and talked to so many engineers in the world, but she did in one weekend. As a programmer, she felt a little proud of learning to review peer's code and also recommend a book "

Last long weekend, she managed to finish 11 mock experience. So she almost finished her second round. The fact is that second round is

The fact is that she met strong peers who shared her importance to learn and write good clean code, specially recursive, DFS, and also the peer still practices. The meeting is short but she feels that the study group formed through the discussion is also very rewarding experience, she would be a nice algorithm teacher one day if she continues.

It is fun to play with a peer. One day, Julia met a peer again and she was too busy to follow the peer's idea to solve the problem, but she knew that the peer was working hard and the idea needs to be tuned. Julia likes to gain some skills to be a professional interviewer one day, so she learned quickly to say sorry, not followed closely with the ideas in the code. Good heart leads to a new world, the peer told her that there is something new and different, she was well received with a tip.

"

Related to tennis sports, Julia learns to treat peers equally and be supportive in mock experiences.

Julia missed how a professional mock experience will look like. She booked one mock and surprisingly she got one in less than one week.

### Introduction

Proverbs 17:22, Julia's favorite verse. "

The mock experience is related to people skills and Julia started to learn how to make most from it. She has limited resource and limited budget to try new things. She chose free mock experience, she never tried any paid mock experience, but she did feel that she has to make mock experience very good learning activities.*". Every time Julia is too busy to work on something, she starts to check whether she has the feeling of a cheerful heart, specially she likes to stay late past midnight to work on a contest algorithm. She likes to share a story of a cheerful heart, and ends her weekend with some good story.***A cheerful heart is good medicine, but a crushed spirit dries up the bones**Always have a cheerful heart on your own or peer's mistakes, they are the best friends of algorithm problem solvers. Coding is a crafting skills, talk about mistakes, journal the transcript, and then get back to compete again.

### 4 Sum

People with top talent to attend mock usually are very young and just start his/ her career, and one time Julia felt that the hints were too strong in the first 5 minutes, she had to take the hint given by peer. The algorithm is 4 sum, Leetcode 18. Second time she was mocked again using similar algorithm like 4 sum, she decided to work on practice Leetcode 4 sum. Here is her practice C# code. Her second mock code is here.

### Edit Distance

Julia learned so many lessons from her own mistakes. She could not figure out dynamic programming

**in her first round mock in 2017. Overall, she almost failed at least 20% - 30% in her first round.***Edit Distance*Julia wrote a bug on spiral matrix first as an interviewee, and then she interviewed some one the spiral matrix. She observed carefully the peer's performance, she had more confident to make the code perfect later on.

Every peer get stumbles in mock experience, she reminds herself not long ago she had same experience. Julia felt so connected through mock experience.

She suddenly found out that she never met and talked to so many engineers in the world, but she did in one weekend. As a programmer, she felt a little proud of learning to review peer's code and also recommend a book "

**".***The Art of Readable Code*Last long weekend, she managed to finish 11 mock experience. So she almost finished her second round. The fact is that second round is

*learning*round.**, not using compiler, use your own whiteboard techniques.***Test your own code*### Reverse string

It is fun to play with a peer. One day, Julia met a peer again and she was too busy to follow the peer's idea to solve the problem, but she knew that the peer was working hard and the idea needs to be tuned. Julia likes to gain some skills to be a professional interviewer one day, so she learned quickly to say sorry, not followed closely with the ideas in the code. Good heart leads to a new world, the peer told her that there is something new and different, she was well received with a tip.

"

**". That is the famous tennis professional player's quote. Only those survive with strong mind set, and determination, and the hard work training, practice.***Every player knows how to play tennis*Related to tennis sports, Julia learns to treat peers equally and be supportive in mock experiences.

Julia missed how a professional mock experience will look like. She booked one mock and surprisingly she got one in less than one week.

### Study and talk

Julia wrote a blog about the study "Does mock make difference", and then she moved herself to next stage in her practice, know a professional interviewer with thousand experience, and also learn to mark herself with a mark, May 27, 2017, she got a mark which is called passing the bar - 2.5.

Good heart leads to a new world. Julia likes to show people that she has determination to gain skills in algorithm and data structure, and is working hard on the improvement. Still exploring...

Julia understood that those contest practice with medium levels are very helpful, she prepared herself, she felt that the depth first search, recursive function call is so important to learn.

She forgets to write a base case in DFS algorithm, still she needs to the hint to go over the test case and then find out that she lets the loop forever because of that.

She forgets to write a base case in DFS algorithm, still she needs to the hint to go over the test case and then find out that she lets the loop forever because of that.

### City Construction - world codesprint 11

May 27, 2017

Now it is 3:08pm, 18 hours left for the contest. Julia was busy this morning. She had her first mocking experience with a new company called refdash.com. She could not believe that after 40 mocking experience, she started to enjoy solving algorithm and data structure problems and survived first algorithm.

After 10:00 am - 11:30 am mocking experience, she went back to the .NET user group and had a lunch, attended one hour session for a talk. She quit early because she likes to get some learning experience through those four algorithms. One medium level, one hard level, two expert levels algorithms in world codesprint 11.

Julia likes to play contest and she just could not believe that she could not take whole afternoon to sit in lectures. She likes to play competition, and get challenged on algorithms. Julia is an active learner, she likes to try new things, build something using her crafting skills, specially algorithm problems.

May 28, 2017 1:38 pm

Code submitted in the contest is here. Score 0. Will find out why test case 1 fails, there are 10,000 roads. Timeout is the issue.

The union find algorithm is the classical algorithm, which can be applied to this "

### Introduction

Now it is 3:08pm, 18 hours left for the contest. Julia was busy this morning. She had her first mocking experience with a new company called refdash.com. She could not believe that after 40 mocking experience, she started to enjoy solving algorithm and data structure problems and survived first algorithm.

After 10:00 am - 11:30 am mocking experience, she went back to the .NET user group and had a lunch, attended one hour session for a talk. She quit early because she likes to get some learning experience through those four algorithms. One medium level, one hard level, two expert levels algorithms in world codesprint 11.

Julia likes to play contest and she just could not believe that she could not take whole afternoon to sit in lectures. She likes to play competition, and get challenged on algorithms. Julia is an active learner, she likes to try new things, build something using her crafting skills, specially algorithm problems.

### Coding in the contest

Code from 10:00 pm to 3:00 am, score 0 even though the algorithm passed a few of test cases Julia set up, also sample test case. Great learning opportunity after the contest.

Here is the progress report.

### Follow up after the contest

May 28, 2017 1:38 pm

Code submitted in the contest is here. Score 0. Will find out why test case 1 fails, there are 10,000 roads. Timeout is the issue.

The union find algorithm is the classical algorithm, which can be applied to this "

**" algorithm.**

*City construction*## Friday, May 26, 2017

### Simple File Commands - world codesprint 11

May 26, 2017

It is 11:51 pm. Julia likes to check her progress of the contest. She likes to work on every algorithm, and take the chance to learn something, specially hard and expert level algorithms.

### Introduction

### Status report

### Follow up after the contest

May 28, 2017

Code submitted in the contest is here, score 20 out of maximum score 40.

## Thursday, May 25, 2017

### Data Structures & Algorithms with JavaScript - Michael McMillan

May 25, 2017

It is the best time of the year to learn JavaScript. Julia chooses to read the book and learn more about JavaScript. She likes to think problem solving using JavaScript in the future, so it is better to start to build hours to practice, read the book 30 minutes a time.

### Introduction

### Book reading

### Coding Interviews - Harry He

May 25, 2017

It is such a great book and Julia read the book back in 2015. Now it is the time to review the book again.

Leetcode 295. Find median from data stream - discussion panel is here.

C# solution using SortedSet. The C# code to study is here.

C# solution using MinHeap/ MaxHeap - self defined. The study code is here.

Read blog about the discussion again - link is here - the blog on ardendertat.com

A little confused about solution discussed in the book, look up Google and then find this blog on geeksforgeeks:

Dyanmic programming / Set 25 ( Subset Sum Problem), recursive and also dynamic programmng solution.

Study leetcode 416: partition equal subset sum. The problem link is here.

Amazonian - USC alumni - Xie Tao - Leetcode profile is here.

Study the solution:

Java dynamic programming solution is here.

Study Leetcode 39: Combination Sum,

Julia's C# practice is here.

Leetcode 40 Combination Sum II.

Julia's C# practice is here.

Leetcode 239 Sliding window maximum

### Introduction

### Book reading

**: Median of a stream (Julia's ranking: 10 out of 10 May 31, 2017)**

*Question 69*Leetcode 295. Find median from data stream - discussion panel is here.

C# solution using SortedSet. The C# code to study is here.

C# solution using MinHeap/ MaxHeap - self defined. The study code is here.

Read blog about the discussion again - link is here - the blog on ardendertat.com

**: binary tree is balanced? (Julia's ranking: 8 out of 10 May 31, 2017)**

*Question 85***: Given an array, check whether it contains a subset of numbers whose sum equals to 0**

*Algorithm 90*A little confused about solution discussed in the book, look up Google and then find this blog on geeksforgeeks:

Dyanmic programming / Set 25 ( Subset Sum Problem), recursive and also dynamic programmng solution.

Study leetcode 416: partition equal subset sum. The problem link is here.

Amazonian - USC alumni - Xie Tao - Leetcode profile is here.

Study the solution:

Java dynamic programming solution is here.

Study Leetcode 39: Combination Sum,

Julia's C# practice is here.

Leetcode 40 Combination Sum II.

Julia's C# practice is here.

**Algorithm 93: Maximum in Queue**

Leetcode 239 Sliding window maximum

**Algorithm 98: Most profit from stock**

**June 8, 2017**

**Leetcode 121**

**Julia's C# practice is here.**

**Leetcode 122**

**Julia's C# practice is here.**

## Wednesday, May 24, 2017

### Leetcode 48: Image Rotate

May 24, 2017

Plan to work on image rotate.

The idea is to visit nodes in the matrix using the order of top row, right column, bottom row and then left column. So the rotate 90 degree clockwise is to shift the array to left.

C# practice is here.

The idea is to first reverse up to down, then swap the symmetry.

C# practice is here.

Plan to work on image rotate.

The idea is to visit nodes in the matrix using the order of top row, right column, bottom row and then left column. So the rotate 90 degree clockwise is to shift the array to left.

C# practice is here.

The idea is to first reverse up to down, then swap the symmetry.

C# practice is here.

### Leetcode 151: reverse words in a string

May 24, 2017

Problem statement is here.

C# practice is here. Need to work on failed test cases, multiple space, "a b" should be reversed to "b a".

April 16, 2017

Mocking experience, reverse words in a string, C# code is here.

June 20, 2017

Mocking experience, reverse words in a string, C# code is here.

Julia learned the lesson how to work on linear scan array hard lesson through Leetcode contest in May, she spent over 40 minutes on one algorithm, and then she read the idea to spend 5 minutes less to write very clear solution. The blog is called Leetcode 605: Can plant flower.

Problem statement is here.

C# practice is here. Need to work on failed test cases, multiple space, "a b" should be reversed to "b a".

### Follow up

Mocking experience, reverse words in a string, C# code is here.

June 20, 2017

Mocking experience, reverse words in a string, C# code is here.

Julia learned the lesson how to work on linear scan array hard lesson through Leetcode contest in May, she spent over 40 minutes on one algorithm, and then she read the idea to spend 5 minutes less to write very clear solution. The blog is called Leetcode 605: Can plant flower.

## Tuesday, May 23, 2017

### Leetcode 37: Sudoku Solver

May 23, 2017

Sudoku solver is the most classical algorithm to apply

Most important design is about

The C# code practice is here.

May 25, 2017

It is also very good experience to use Sudoku Solver algorithm to conduct mocking experience. Julia did her first mocking experience using the algorithm as an interviewer.

June 13, 2017

It is very good experience to write sudoku in mocking experience, this is the third time Julia worked on Sudoku for mocking experience.

Julia put the code into Visual Studio to compile and here is her C# practice code.

Here are two mistakes in writing through mocking experience:

One compiler error in mocking writing,

add type conversion by adding (char), and also (number + '0')

One compiler error, duplicate variable inside for loop on

Try to pass online judge, and then find the bug on

Julia still remembered that she got some great advice on her

### Introduction

**Depth First Search (DFS)**using recursion and also use back tracking as well. Julia had a very good experience in May 22, 2017, she had chance to learn to write a short version of depth first search coached by her mocking peer.Most important design is about

**base case**. To make the implementation as simple as possible, DFS algorithm can start from the matrix left top corner, and then scan from left to right, top to bottom, if the row is bigger than 8, then it finds a solution.### Algorithm Study

### Algorithm talk

It is also very good experience to use Sudoku Solver algorithm to conduct mocking experience. Julia did her first mocking experience using the algorithm as an interviewer.

June 13, 2017

It is very good experience to write sudoku in mocking experience, this is the third time Julia worked on Sudoku for mocking experience.

Julia put the code into Visual Studio to compile and here is her C# practice code.

Here are two mistakes in writing through mocking experience:

One compiler error in mocking writing,

**,***line 61*add type conversion by adding (char), and also (number + '0')

*line 61 board[row, col] = (char)(number + '0'); // add '0'*One compiler error, duplicate variable inside for loop on

**, change col to column; line 91, row is changed to rowIndex.***line 82*Try to pass online judge, and then find the bug on

**. C# code is here.***line 84, 93, 111**line 84 if (board[row, column] - number == '0') // should be '0', not 0*

### Actionable Item

Julia still remembered that she got some great advice on her

**mocking experience using Sudoku, and then she was coached by the peer to use DFS starting from***second***and set the base case to***(0, 0)***.***row > 8*### Leetcode 54: Spiral Matrix

May 23, 2017

It is a good habit to review the code and then run a few test case to verify the code. Once you finish the white board testing, you tell that you are ready and code is complete. As a software programmer, it is not too late to start to build a habit, examine the code with coding style, run white board testing, and think about possible bugs. Have a high standard, push yourself.

C# code submission is here. Leetcode discussion link is here. Plan to ask a question on codereview.stackexchange.com.

Build a ritual to do white board testing, and write down the test case next to each line of code.

### Introduction

### Code design talk

C# code submission is here. Leetcode discussion link is here. Plan to ask a question on codereview.stackexchange.com.

Build a ritual to do white board testing, and write down the test case next to each line of code.

## Monday, May 22, 2017

### Bronze medal celebration - week code 32 on hackerrank

May 22, 2017

Study discussion, link is here.

### Introduction

It is a small contest but Julia learned how to advance her algorithm research and problem solving skills. Julia still has to learn how to identify advanced algorithm as a classical algorithm in the contest, and then improve her performance from less than 10% to more. No matter how good you are as a programmer, if you cannot relate to the specific advanced algorithm or data structure, the timeout will cause you lose 90% score.

Julia dedicated her effort to work on last two algorithms in the week code 32, she was busy with near 10 mocking experience May 20 - 21 weekend, and then she only had chance to work on those two algorithms. She did not spend time to work on two medium algorithm at all.

Julia dedicated her effort to work on last two algorithms in the week code 32, she was busy with near 10 mocking experience May 20 - 21 weekend, and then she only had chance to work on those two algorithms. She did not spend time to work on two medium algorithm at all.

The score is so low, but the bronze medal is the celebration of her brave to solve hard and expert level algorithm, prepare herself to advance her study to two more advanced algorithms - one is called network flow and the another one is called treap tree.

### Actionable Items

Study discussion, link is here.

### Leetcode 114: Flatten Binary Tree to Linked List

### Treap algorithm

May 22, 2017

Plan to study treap algorithm. Here is the algorithm on geeksforgeeks.com.

Julia played the contest of week code 32, she had a lot of fun to play with the algorithm

Plan to study treap algorithm. Here is the algorithm on geeksforgeeks.com.

Julia played the contest of week code 32, she had a lot of fun to play with the algorithm

**. After the contest, she learned that the algorithm can be solved using treap algorithm.***special substring*### Leetcode 39: Combination Sum

May 22, 2017

Plan to study the video about Leetcode 39: combination sum. Here is the video link by Yu Zhou.

Plan to study the video about Leetcode 39: combination sum. Here is the video link by Yu Zhou.

### Leetcode 78: Subsets

May 22, 2017

To get back to normal daily grind, Julia chooses to follow the video from Yu Zhou, learn one algorithm a time, here is the video link on youtube.com.

### Introduction

It is so much fun to play hackerrank contest, Julia has to learn how to do a quick research how to identify what kind of advanced algorithm for those hard or expert level algorithm. It is so frustrated to see the score 7 out of 90 on special substrings algorithm.To get back to normal daily grind, Julia chooses to follow the video from Yu Zhou, learn one algorithm a time, here is the video link on youtube.com.

### Leetcode 78 Subsets

### The element of style

May 22, 2017

Plan to read the book reading: The element of style.

It is a good idea to read a short book and then learn something about English writing. It is inspired by the article Elements of JavaScript style written by Eric Elliot.

Plan to read the book reading: The element of style.

It is a good idea to read a short book and then learn something about English writing. It is inspired by the article Elements of JavaScript style written by Eric Elliot.

### Ford-Fulkerson Algorithm for Maximum Flow problem

May 22, 2017

It is time to learn a new algorithm called Ford-Fulkerson for maximum flow problem. Here is the one article to study on geeksforgeeks.com.

The link is here.

Julia worked on week contest 32, and there is the algorithm she chose to work on called Boxes and Balls. She learned after the contest that the algorithm should be solved using network flow knowledge.

### Introduction

The link is here.

Julia worked on week contest 32, and there is the algorithm she chose to work on called Boxes and Balls. She learned after the contest that the algorithm should be solved using network flow knowledge.

### Algorithm study

Max flow problem introduction on geeksforgeeks.com is here.### The art of programming contest

May 22, 2017

Plan to read the book "

"I studied Programming Challenges 3, Programming Contests, Hitchhiker's Guide to Competitive Programming and the Art of Programming Contests. I know what the most frequent algorithms is."

Write down a note to finish 30 minutes reading each time here.

1. May 22, 2017 12:04 pm - 12:34 pm

Chapter 2 Game Plan for a contest

Plan to read the book "

**The art of programming contest**". Julia read the discussion of special substrings algorithm in the week code 32 contest, here is the discussion link. Read the discussion:"I studied Programming Challenges 3, Programming Contests, Hitchhiker's Guide to Competitive Programming and the Art of Programming Contests. I know what the most frequent algorithms is."

Write down a note to finish 30 minutes reading each time here.

1. May 22, 2017 12:04 pm - 12:34 pm

Chapter 2 Game Plan for a contest

## Sunday, May 21, 2017

### Special substring - week of code 32

May 21, 2017

Special substring is the last algorithm in the week of code 32, and it's max score 81, success rate 9.03%, difficult level is expert, and it ends in 14 hours. Now it is 9:52 am. Julia has to work on the algorithm before 12:00 pm before her first mocking experience starts. She booked herself 5 mocking experience today, and in-between she likes to work on those 3 algorithms in the week of code 32, two other medium algorithms as well.

The problem statement is here.

###

It is a good idea to do comparison, and then determine where to gain more points in less time, and also learn and have some fun.

3:22 pm

Work on timeout issue, pass test case 9, score 20.06

3:37 pm, fix the timeout issue, now score 23

Read the discussion:

I studied Programming Challenges 3, Programming Contests, Hitchhiker's Guide to Competitive Programming and the Art of Programming Contests. I know what the most frequent algorithms is.

May 22, 2017

code submission is here in the contest, score 6 out of 90.

### Introduction

The problem statement is here.

### Coding in the contest

2:43 pm, first submission, score 16.70. Have timeout issue, wrong answers for the first 20 test cases.

###

Ranking study

It is a good idea to do comparison, and then determine where to gain more points in less time, and also learn and have some fun.

### Timeout problem solving

3:22 pm

Work on timeout issue, pass test case 9, score 20.06

### One more progress

3:37 pm, fix the timeout issue, now score 23

### Discussion panel

Read the discussion:

I studied Programming Challenges 3, Programming Contests, Hitchhiker's Guide to Competitive Programming and the Art of Programming Contests. I know what the most frequent algorithms is.

### Follow up

May 22, 2017

code submission is here in the contest, score 6 out of 90.

### Can mock make difference?

May 21, 2017

It is a good habit to do some small topic research and then figure out what to look into. Julia did 4 mock experience today, and then she likes to do some research, the topic is "Can mock make difference?"

Mock interview makes difference.

Things Julia learned through mock experience. Every peer has different talent, different learning style, Julia learns to speak slowly, clearly, make good points, and then present best talent to the peer. And also Julia learns to review the code carefully as a peer, give hints less or more.

1. Use headset to talk, a few people complained about echo sound.

2. Do not be hacker in mock interview. I have to take the hint, follow the hint.

3. Need to work on the attitude. Set up camera properly, and also give people good impression. Practice makes perfect.

4. Julia enjoyed to learn C++, Ruby and Python through mock experience.

5. Julia learns the importance to practice algorithm and data structure. Peers share their insights.

It is the great to learn algorithms through the mock experience. Now Julia is easy to figure out how people get stuck on one algorithm, one specific issue. She can relate her performance to one of peers, and she knows that her next performance level and how great it should be. She can easily relate to one of her peers and then work hard to improve. She can manage her own thoughts and expectation of her own performance realistically.

Learning algorithm is easy to reach a plateau no matter what you take, by learning from practice, a book, a contest, a code review on the stackexchange.com. But learning from the peer, it is like having a coach sometimes, the discussion part is also exciting sometimes.

Met peers from New York, Indiana, country of Ireland, Taiwan. Two new graduates and one experienced "It is always in day 1".

Julia experienced two times

She learned through near 30 mock experience, the experience taught her to be super patience.

Last 3 year she only did around 40 mock experience, but 30 of them she did in last 2 months. She first time experience how good she can do to compare with others, if she does not practice at all. To be a learner she has to step out from comfortable zone, meet and talk about algorithms with peers.

Besides algorithm problem solving, there are other traits and characters to help people identify who you are, the way you present, the attitude, if you have high standard for your own code. Have you worked on the basics, coding style, and apply test case in daily programming or not. 30 minutes is a great window for the peer to observe you.

If you are really smart and have a good match with both good performance, then you will find that you two will end up having some time to chat something more interesting, the book you like to recommend, the place you live and sharing of career growth, and other things.

One day Julia will get used to mock experience, and accumulate over 100 times experience; What she will still excite to go for 101?

Before Julia does not care how others are achieved so much, now she knows that people are working hard and keep quiet, and practice again and again until he/ she feels comfortable with the trials.

Julia knows that each company what kind of level programmers are working there and how she should work on to be competitive, catch up.

Specially Julia thought about young graduate from university bachelor or master degree program, without much experience, what makes them so competitive? The top ranking computer science university, the degree, or high performance in the study of university degree?

###

Julia has to speak slowly, and also get used to share what she learns. She likes to see if the voice training drill can help her, it is not easy to reduce the accent, improve the pronunciation.

The same idea is in James 1:19, "let every person be quick to hear, slow to speak." Just speak slowly.

Mark 30+ mock interview experience, 40+ mock interview experience, one algorithm 3+ mock interviews, 5+ mock interviews,

30+ mock experience:

40+ mock experience: You start to ask what if you are a professional interviewer, interview more than one thousand people already? What are you looking for through the candidates?

Assuming that you have chance to meet people with the range of performance from top 70% to 30%. But with 40+ mock experience, you may have a surprise with top talent and top performance.

one algorithm the first mock -

one algorithm 5+ mock - No matter how busy you are, you will start to look into the algorithm, try to understand various solutions. Big surprise for Julia to learn Leetcode 10 recursion tree related issues.

Always get prepared. Prepare extended question until the peer will fail, then you can measure how deep the strength the peer has.

100+ mock interview experience - It is the first time to learn how to give good advice on hard algorithm Leetcode 10 problem solving, try to explain recursion branches concept. Julia practised over five times Leetcode 10 algorithm.

### Introduction

### Study

Mock interview makes difference.

Things Julia learned through mock experience. Every peer has different talent, different learning style, Julia learns to speak slowly, clearly, make good points, and then present best talent to the peer. And also Julia learns to review the code carefully as a peer, give hints less or more.

1. Use headset to talk, a few people complained about echo sound.

2. Do not be hacker in mock interview. I have to take the hint, follow the hint.

3. Need to work on the attitude. Set up camera properly, and also give people good impression. Practice makes perfect.

4. Julia enjoyed to learn C++, Ruby and Python through mock experience.

5. Julia learns the importance to practice algorithm and data structure. Peers share their insights.

It is the great to learn algorithms through the mock experience. Now Julia is easy to figure out how people get stuck on one algorithm, one specific issue. She can relate her performance to one of peers, and she knows that her next performance level and how great it should be. She can easily relate to one of her peers and then work hard to improve. She can manage her own thoughts and expectation of her own performance realistically.

Learning algorithm is easy to reach a plateau no matter what you take, by learning from practice, a book, a contest, a code review on the stackexchange.com. But learning from the peer, it is like having a coach sometimes, the discussion part is also exciting sometimes.

Met peers from New York, Indiana, country of Ireland, Taiwan. Two new graduates and one experienced "It is always in day 1".

### Recursive Syndrome

**in real experience spanning from 2015 to 2017. She asked herself why, between those 3 years she practiced so many algorithms, why she still failed on the basics, not asking the choice of iterative or recursive, not knowing depth first search (DFS) algorithm can be implemented using recursive intuitively.***recursive syndrome*She learned through near 30 mock experience, the experience taught her to be super patience.

Last 3 year she only did around 40 mock experience, but 30 of them she did in last 2 months. She first time experience how good she can do to compare with others, if she does not practice at all. To be a learner she has to step out from comfortable zone, meet and talk about algorithms with peers.

Besides algorithm problem solving, there are other traits and characters to help people identify who you are, the way you present, the attitude, if you have high standard for your own code. Have you worked on the basics, coding style, and apply test case in daily programming or not. 30 minutes is a great window for the peer to observe you.

If you are really smart and have a good match with both good performance, then you will find that you two will end up having some time to chat something more interesting, the book you like to recommend, the place you live and sharing of career growth, and other things.

### What if

Before Julia does not care how others are achieved so much, now she knows that people are working hard and keep quiet, and practice again and again until he/ she feels comfortable with the trials.

Julia knows that each company what kind of level programmers are working there and how she should work on to be competitive, catch up.

Specially Julia thought about young graduate from university bachelor or master degree program, without much experience, what makes them so competitive? The top ranking computer science university, the degree, or high performance in the study of university degree?

###

Learn to play

### It is very good topic to study how to work smart with other people. Through mock experience, Julia learns to improve her speaking English.

Julia has to speak slowly, and also get used to share what she learns. She likes to see if the voice training drill can help her, it is not easy to reduce the accent, improve the pronunciation.

The same idea is in James 1:19, "let every person be quick to hear, slow to speak." Just speak slowly.

### Actionable Items

Mark 30+ mock interview experience, 40+ mock interview experience, one algorithm 3+ mock interviews, 5+ mock interviews,

30+ mock experience:

40+ mock experience: You start to ask what if you are a professional interviewer, interview more than one thousand people already? What are you looking for through the candidates?

Assuming that you have chance to meet people with the range of performance from top 70% to 30%. But with 40+ mock experience, you may have a surprise with top talent and top performance.

one algorithm the first mock -

**- you start to pay attention more on algorithm itself, you do not care about the ratings you get, you know that you just worked on the algorithm. You love to learn, that is the reason you like to use the algorithm again and again, see how peer learn and solve the algorithm with/ without your contributions.***one algorithm 1+ mock***- You cannot believe how busy you are. After 3+ mock on same algorithm, you look into related algorithms. For example, Leetcode 33, 153, 189. You reviewed the discussion on leetcode for different opinions.***one algorithm 3+ mock*one algorithm 5+ mock - No matter how busy you are, you will start to look into the algorithm, try to understand various solutions. Big surprise for Julia to learn Leetcode 10 recursion tree related issues.

**- Julia met a peer and the peer asked to work on the extended problem since the algorithm is easy and quick recursive function.***70+ mock interview experience***- Julia learned the performance lesson 5 minutes vs 48 minutes on easy algorithm, so she applied her learning quickly and shortened the time to 5 minutes writing in mock as well in June - Leetcode 151.***Leetcode weekly contest makes difference***- It is also a good idea to extend the problem for very competitive peer, change the algorithm if you think that peer will accept it. For example, inorder BST successor can be solved using/ without parent node pointer, there is Leetcode algorithm Inorder Successor. A few of discussions are very detail on how to use DFS search to find the solution.***90+ mock interview experience*Always get prepared. Prepare extended question until the peer will fail, then you can measure how deep the strength the peer has.

100+ mock interview experience - It is the first time to learn how to give good advice on hard algorithm Leetcode 10 problem solving, try to explain recursion branches concept. Julia practised over five times Leetcode 10 algorithm.

## Saturday, May 20, 2017

### Balls and Boxes - balls and boxes

May 20, 2017

It is a busy Saturday morning, Julia setup two mocking experience 10:00 am and 12:00 am, and then another one is 4 pm, last one is 8 pm. So in-between she likes to work on week of code 32. Now she has 40 minutes to work on the algorithm, from 3:10 pm - 3:50 pm.

Problem statement of Balls and Boxes is here.

### Introduction

Problem statement of Balls and Boxes is here.

### Algorithm

Progress report - 5/21/2017 12:28 am

After hours of writing the code, from 9:00 pm to 12:28 am, over 3 hours work, first success submission scored 38 points with only first 4 test cases, failed #2 test case. There are 5 more test cases are not tested.

The score will go down more because there are more failure test cases. Right now, the maximum score is lowered to 57 from 70 since the algorithm has the full score the first day, and then go down next day to 63, go down to 57 the third day.

The score will go down more because there are more failure test cases. Right now, the maximum score is lowered to 57 from 70 since the algorithm has the full score the first day, and then go down next day to 63, go down to 57 the third day.

And the ranking on lead board moved forward from 3000+ to 1022. Let us compare to a Googler:

Julia looked into the success rate first, and then she decided to work on this hard algorithm. The whole day Julia was busy with mocking interview, 4 mocking experience. She was glad that her effort on balls and boxes improved her ranking over 1000 once.

Julia reviewed her code and then she tried to fix the test case 2. So she likes to journal some writing on the paper about her thinking process and then share it after the contest.

Learn through the thinking process. Write down all test cases tested in the contest.

May 21, 2017 9:58 am

###

May 22, 2017

Code written in the contest is here. Score 6 out of 70.

Julia reviewed her code and then she tried to fix the test case 2. So she likes to journal some writing on the paper about her thinking process and then share it after the contest.

Learn through the thinking process. Write down all test cases tested in the contest.

May 21, 2017 9:58 am

###

Follow up

May 22, 2017

Code written in the contest is here. Score 6 out of 70.

## Friday, May 19, 2017

### Book reading: The art of readable code

### May 19, 2017

### Introduction

For medium level algorithm, Julia stumbled badly on Rookie3 maximum score algorithm. She tried to look up the lead board and then tried to find out a good solution to work on her skills, and then she figured out that it is better to work on the basics. She remembered that she read a book to teach how to set up a good test case, and she likes to enhance her skills to use test case for the algorithm analysis.

The book is called "The art of readable code", chapter 14: testing and readability.

### Leetcode 480: sliding window median

May 19, 2017

Work on the algorithm Leetcode 480: sliding window median, the blog is here. Leetcode weekly contest 14.

Work on the algorithm Leetcode 480: sliding window median, the blog is here. Leetcode weekly contest 14.

## Tuesday, May 16, 2017

### Leetcode 582: Kill Process

May 16, 2017

Problem statement is here.

C# practice is here.

Leetcode discussion link is here. Learn to get involved in Leetcode community. Share the code first.

Study code is here. One more C# practice.

Watch Googler - Yu Zhou - Leetcode videos on youtube.com.

Will write down C# practice using Yu Zhou's idea in the the video - link is here.

C# code is here.

Work on the algorithm Leetcode 480: sliding window median, the blog is here. Leetcode weekly contest 14.

Problem statement is here.

### Introduction

It is a binary tree data structure, and it needs to use BFS/
DFS search to find all children.

### Problem solving

Leetcode discussion link is here. Learn to get involved in Leetcode community. Share the code first.

Study code is here. One more C# practice.

Watch Googler - Yu Zhou - Leetcode videos on youtube.com.

Will write down C# practice using Yu Zhou's idea in the the video - link is here.

C# code is here.

### Actionable Item

Work on the algorithm Leetcode 480: sliding window median, the blog is here. Leetcode weekly contest 14.

### Leetcode 581: Shortest unsorted continuous array

May 16, 2017

Problem statement is here. The algorithm is easy level. The target is to solve it in 30 minutes.

It took more than 30 minutes to come out the sorting idea, and just compare to sorted array.

C# practice is here.

Leetcode discussion link is here.

### Introduction

Julia likes to be a good problem solver, one thing she starts to do in this May is to solve algorithm problems every day. If she solves 2 algorithm problems a day, then one month she can finish 60 of them.

One of ideas is to work on past over 32 Leetcode weekly contest, and try to solve weekly contest algorithms. Each contest has 4 algorithms, so there are over 100 algorithm.

Top performers can solve 4 algorithms in a hour, based on the lead board of Leetcode weekly contest. But Julia sets the target to solve first easy algorithm in half hour, and then second algorithm in medium level one hour.

One of ideas is to work on past over 32 Leetcode weekly contest, and try to solve weekly contest algorithms. Each contest has 4 algorithms, so there are over 100 algorithm.

Top performers can solve 4 algorithms in a hour, based on the lead board of Leetcode weekly contest. But Julia sets the target to solve first easy algorithm in half hour, and then second algorithm in medium level one hour.

### Problem Solving

It took more than 30 minutes to come out the sorting idea, and just compare to sorted array.

C# practice is here.

Leetcode discussion link is here.

## Sunday, May 14, 2017

### Testable JavaScript

May 14, 2017

As a hackerrank contest player, Julia likes to do some research on how to improve her performance. She was surprised that she could not figure out easy algorithm on Hackerrank last year, and then she posted questions on codereview.stackexchange.com, and then she quickly followed the advice. She felt more confident on easy algorithm on hackerrank contest. Here is one of questions she asked on a easy algorithm called Spiral Message.

For medium level algorithm, Julia stumbled badly on Rookie3 maximum score algorithm. She tried to look up the lead board and then tried to find out a good solution to work on her skills, and then she figured out that it is better to work on the basics. She remembered that she read a book to teach how to set up a good test case, and she likes to enhance her skills to use test case for the algorithm analysis.

The book is called "The art of readable code", chapter 14: testing and readability.

It is always a good idea to read book written by google programmers, specially short books like 200 pages.

It is a good idea to read the book called "Testable JavaScript" again in 2017.

Choose a good fight, instead of fighting against the hackerrank contest lead board, Julia likes to follow the author, Mark Ethan Trostler, a googler by reading the book again.

The ideal case is that Julia will design the algorithm using a new school technique, by working smart on testable idea. Really focus on a small unit test case, instead of focusing on recurrence formula, analysis of the algorithm. Will try to read the book again in 2017 and see if there are some valuable ideas in the book.

Show how hard Julia tries to study the book and gather all topics she should learn again.

May 14, 2017 3:20 pm - 4:29 pm

Read the book from page 1 - 13, page 35 / 273, chapter one.

Notes:

comand query separation - commands are setters and queries are getters.

internal and external names of docRoot versus realRoot

A better solution is to use private properties with public getters and setters.

Try to read JavaScript code and understand the discussion - maybe I should put the code in html page next time.

Try to complete chapter 2 reading first.

####

independent paths

jsmeter - a command-line tool

Read the article about Complexity metrics - link is here.

multiple exits -

bad fix probability

Elements of JavaScript style - article link is here. Chinese translated version is here.

12 books every JavaScript developer should read - article link is here.

Read the book "The art of readable code" again. First reading is in 2014, Oct. 31, 2014.

Chapter 8: Break down giant expression - favorite example:

Two ranges does not overlap

### Introduction

For medium level algorithm, Julia stumbled badly on Rookie3 maximum score algorithm. She tried to look up the lead board and then tried to find out a good solution to work on her skills, and then she figured out that it is better to work on the basics. She remembered that she read a book to teach how to set up a good test case, and she likes to enhance her skills to use test case for the algorithm analysis.

The book is called "The art of readable code", chapter 14: testing and readability.

It is always a good idea to read book written by google programmers, specially short books like 200 pages.

### Testable JavaScript

It is a good idea to read the book called "Testable JavaScript" again in 2017.

Choose a good fight, instead of fighting against the hackerrank contest lead board, Julia likes to follow the author, Mark Ethan Trostler, a googler by reading the book again.

The ideal case is that Julia will design the algorithm using a new school technique, by working smart on testable idea. Really focus on a small unit test case, instead of focusing on recurrence formula, analysis of the algorithm. Will try to read the book again in 2017 and see if there are some valuable ideas in the book.

Show how hard Julia tries to study the book and gather all topics she should learn again.

### Book reading

Read the book from page 1 - 13, page 35 / 273, chapter one.

### Chapter 2. Complexity

#### Code size

Notes:

comand query separation - commands are setters and queries are getters.

internal and external names of docRoot versus realRoot

A better solution is to use private properties with public getters and setters.

Try to read JavaScript code and understand the discussion - maybe I should put the code in html page next time.

Try to complete chapter 2 reading first.

#### JSLint

####

Cyclomatic Complexity

independent paths

jsmeter - a command-line tool

Read the article about Complexity metrics - link is here.

multiple exits -

bad fix probability

### Actionable Items

12 books every JavaScript developer should read - article link is here.

Read the book "The art of readable code" again. First reading is in 2014, Oct. 31, 2014.

Chapter 8: Break down giant expression - favorite example:

Two ranges does not overlap

## Saturday, May 13, 2017

### Graph or permutations with constraints?

May 13, 2017

Plan to read this algorithm called "Graph or permutations with constraints?". The coding blog link is here.

Plan to read this algorithm called "Graph or permutations with constraints?". The coding blog link is here.

## Friday, May 12, 2017

### Maximum Score - Rookie 3 (II)

May 12, 2017

It is a good idea to continue to work on maximum score algorithm, and also ask a question on code review. Learning memoization and bit mask is not an easy task, also Julia likes to learn the time complexity analysis algorithm better through the study.

Julia wrote a blog to document her learning experience on the algorithm, from the contest performance to after-contest catching up.

In order to write a good question on code review, Julia also have to write down some notes from editorial notes from hackerrank on the maximum score algorithm.

Here is the link of editorial notes.

time complexity: O(2

Recursion tree - a major flaw, same recursive call many times; It results in exponential running time.

Read book "Testable JavaScript" and then figure out a few things I can do in order to have a good sense of setting up test cases to help Hackerrank contest.

The algorithm is also on code review.stackexchange.com, the link is here.

### Introduction

It is a good idea to continue to work on maximum score algorithm, and also ask a question on code review. Learning memoization and bit mask is not an easy task, also Julia likes to learn the time complexity analysis algorithm better through the study.

Julia wrote a blog to document her learning experience on the algorithm, from the contest performance to after-contest catching up.

### Code review preparation

C# code in the contest is here. Score 3.5 of 35 points.

May 12, 2017 11:16 pm

Code review of C# code in the contest, and then move the memoization out-of-for-loop, scored 10.50 of 35 points. C# code is here.

Instead of going over the recurrence formula, Julia likes to use an example to explain what can be in memoization. And what is her mistake in the contest? What is the reason causing the false analysis?

Suppose that the array has two numbers,

What is the subproblem of max score?

First, add sum of the array. The array new int[]{1, 2}'s sum is 3.

To choose the last number, two options, either 1 or 2. If the last number is 1, array's index is 0, then the 0th score is (3 - 1) % 1 = 0. Next number is 2, sum is 0, and then the 1th score is 0 % 2 = 0. The sum of score values (0th, 1th) is 0.

In other case, if the last number is 2, array's index is 1, then the score is (3 - 2) % 2 = 1. Next number is 1, sum is 0, and then 0 % 1 = 0. The sum of score values is 1.

From the above two cases, the maximum score is 1 by taking 2 as last number and then taking 1 as the first number. Just remind friendly that the order is opposite from end to start.

The maximum value is to choose maximum value from a set with two values.

The memoization process is to record to Dictionary<string, int> calculated.

["0", 1]

["1", 0]

["", 1]

Calculated variable as Dictionary<string, int> has the following:

[0 1, 0]

[0 2, 0]

[0, 1]

[1 2, 0]

[1, 0]

[2, 1]

[,1]

Debug the code, and check how many times the dictionary is looked up. 3 times.

key = "0 1", "0 2", "1 2".

Draw a recursion tree for this simple test case. Here is the graph:

Do not memo one more item in one recursive call; Stay outside the for loop; Memo before return statement.

Julia, if you are very good at unit testing, and work on simple and very good test case in the design of algorithm, your performance on Hackerrank can improve at least 20%.

It is the first challenge Julia worked on since last January on hackerrank, on the topic of bit mask, dp, memoization, subset. So she likes to make the algorithm everything. Learn one algorithm a time. Do not rush.

Julia likes to review a list of things on the algorithm. Bit mask, memoization, time complexity analysis.

Use bit mask, the code passes all test cases.

C# practice code is here.

### Memoization Analysis Challenge

Instead of going over the recurrence formula, Julia likes to use an example to explain what can be in memoization. And what is her mistake in the contest? What is the reason causing the false analysis?

Suppose that the array has two numbers,

**int[] numbers = new int[]{1, 2}**. The problem is to find the maximum sum such that the order of two numbers to put into scoring make the value maximum.What is the subproblem of max score?

#### Guess what is the subproblem

May 13, 2017 11:03pm

First, add sum of the array. The array new int[]{1, 2}'s sum is 3.

In other case, if the last number is 2, array's index is 1, then the score is (3 - 2) % 2 = 1. Next number is 1, sum is 0, and then 0 % 1 = 0. The sum of score values is 1.

From the above two cases, the maximum score is 1 by taking 2 as last number and then taking 1 as the first number. Just remind friendly that the order is opposite from end to start.

The maximum value is to choose maximum value from a set with two values.

The memoization process is to record to Dictionary<string, int> calculated.

["0", 1]

["1", 0]

["", 1]

#### One more test case

Suppose that the array has two numbers, int[] numbers = new int[]{1, 2, 1}.

[0 1, 0]

[0 2, 0]

[0, 1]

[1 2, 0]

[1, 0]

[2, 1]

[,1]

Debug the code, and check how many times the dictionary is looked up. 3 times.

key = "0 1", "0 2", "1 2".

Draw a recursion tree for this simple test case. Here is the graph:

**Argument:**If you can work on this simple test case and also work out the recursion tree correctly, then I believe that you can solve the problem using memoization and recursive, DP solution correctly as well.#### Common advice

Do not memo one more item in one recursive call; Stay outside the for loop; Memo before return statement.

Julia, if you are very good at unit testing, and work on simple and very good test case in the design of algorithm, your performance on Hackerrank can improve at least 20%.

### Make it all

It is the first challenge Julia worked on since last January on hackerrank, on the topic of bit mask, dp, memoization, subset. So she likes to make the algorithm everything. Learn one algorithm a time. Do not rush.

Julia likes to review a list of things on the algorithm. Bit mask, memoization, time complexity analysis.

Use bit mask, the code passes all test cases.

C# practice code is here.

### Hackerrank Editorial Notes

In order to write a good question on code review, Julia also have to write down some notes from editorial notes from hackerrank on the maximum score algorithm.

Here is the link of editorial notes.

**Julia's note:**time complexity: O(2

^{n}* n)Recursion tree - a major flaw, same recursive call many times; It results in exponential running time.

### Actionable Items

Read book "Testable JavaScript" and then figure out a few things I can do in order to have a good sense of setting up test cases to help Hackerrank contest.

The algorithm is also on code review.stackexchange.com, the link is here.

Subscribe to:
Posts (Atom)