Dec. 13, 2017
It is a long mock interview for me, I worked together with the peer second time, the first time was less than a week ago, the blog is here.
We worked from 10:00 PM to 12:40 AM. I asked two more questions to interview the peer.
The peer helped me to write an algorithm related to recursion, memoization, edit distance problem.
Code review
The C# code is here.
Follow up
After the mock interview, I realized that the memoization has issue. I should declare the memo jagged array with size new int[length1 + 1][length2 + 1] instead of int[length1][length2].
The memoization should record the value for the top row and top column.
Line 42 and line 47.
One thing I can do is to test the code using Leetcode online about memoization design issue. Another one is to read dynamic programming solution, and check the two dimension matrix and its size, base case handling.
The peer brought up a lot of good discussion about the code, I changed the structure of the code to remove redundant code from line 62 to line 73.
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Thursday, December 14, 2017
Object oriented design case study
Dec. 14, 2017
It is time for me to review object-oriented programming, since I start to read C# string, array abstract class, I start to develop a lot of interest, and also I like the lecture note since it is so well prepared. I wrote my lecture note study recently in the blog.
Here is one answer I did back in 2013. I like to review and see if I can do better this time.
Introduction
It is time for me to review object-oriented programming, since I start to read C# string, array abstract class, I start to develop a lot of interest, and also I like the lecture note since it is so well prepared. I wrote my lecture note study recently in the blog.
Here is one answer I did back in 2013. I like to review and see if I can do better this time.
Wednesday, December 13, 2017
Convert to string not using itoa similar function
Dec. 13, 2017
It is challenging to review the code I wrote back to Oct. 2013. I like to review the code as I did review code 8 years ago. My last blog was written in the blog titled: Algorithm: possible triangle.
Here is the code I wrote in October 2013.
Here is the code I wrote in Dec. 13, 2017 using recursive function.
Here is the code I wrote in Dec. 13, 2017 using iterative solution. Need to work on a simple version, I like to practice and learn some APIs, so I kept the version for my learning.
I like to review the code written in 2013, the code is here.
First, the analysis of the algorithm is good in 2013's code, but it takes 10 minutes to write, it should take less than 5 minutes.
The whole paragraph should be organized better. And the comment should be written in the following based on my understanding of depth first search, I learn a lot from Hackerrank contest recursive function failures.
Use depth first search to do the work, recursive function can be designed in the following:
Do at least as possible, smart programmer learns math in computer science first. Being lazy is the status of master of math in computer science. Read more book called basic mathematics in computer science and figure out the depth first search, only thing I need to do is to figure out the base case.
What is base case? One digit number, just output new char[]{(char) (n + '0')}.
What is recurrence formula?
We handle the rightmost digit first, so the string can be concatenated as recursive + base case. If the integer is negative number, '-' should be the first char in the string.
How to get rightmost digit? use % operator, and then work on subproblem which is n/ 10.
Good things in the writing on Dec. 13, 2017. Algorithm is specified using depth first search, recursive function. And then the base case is clearly explained in the paragraph. And then recurrence formula is easy to work on.
Let me go over line by line.
1. Line 20, int[] should be char[]. Return type is char[].
2. line 23, return char array, should be new char[]{'0'}, not "0".
3. line 28, do not change function argument. Declare a new variable.
4. line 25 - 30 should be written in the following:
var isNegative = n < 0;
var postiveOne = isNegative? -n : n;
two lines instead of six lines.
5. line 31, comment: "at least I have one edge case, continue later. need idea?"
Remove the comment!
6. line 37, for(;;), use while(true)
7. line 39, digitOne variable should be rightMost.
8. line 48, 49, move at the beginning, emphasis that it is the base case.
if( loopInt < 10)
{
}
Overall, the code is not structured very well. The code should be self-documented. And the code is written as an iterative solution, but recursive function should be quick and easy solution to write. I was not a very good programmer back in 2013, I have to face the reality after the review of the code.
Let us read the answer Julia wrote Top 10 reasons to write a coding blog on quora.com in 2017.
In order to punish myself do not focus on learning basic mathematics in computer science, I decide to spend at least 5 hours to learn vocabulary in the book, at least collect five hundred words. And those words will be posted here.
This is the drill I learned when I watch China Open tennis professional players did, after they tried to hit Mercede sign, the athletes have to do push up because she/ he fails.
Introduction
Time line: Oct 2013
Here is the code I wrote in October 2013.
Time line: Dec 2017
Here is the code I wrote in Dec. 13, 2017 using recursive function.
Here is the code I wrote in Dec. 13, 2017 using iterative solution. Need to work on a simple version, I like to practice and learn some APIs, so I kept the version for my learning.
Code review
Analysis of algorithm
First, the analysis of the algorithm is good in 2013's code, but it takes 10 minutes to write, it should take less than 5 minutes.
The whole paragraph should be organized better. And the comment should be written in the following based on my understanding of depth first search, I learn a lot from Hackerrank contest recursive function failures.
Depth first search
Use depth first search to do the work, recursive function can be designed in the following:
Do at least as possible, smart programmer learns math in computer science first. Being lazy is the status of master of math in computer science. Read more book called basic mathematics in computer science and figure out the depth first search, only thing I need to do is to figure out the base case.
What is base case? One digit number, just output new char[]{(char) (n + '0')}.
What is recurrence formula?
We handle the rightmost digit first, so the string can be concatenated as recursive + base case. If the integer is negative number, '-' should be the first char in the string.
How to get rightmost digit? use % operator, and then work on subproblem which is n/ 10.
Good things in the writing on Dec. 13, 2017. Algorithm is specified using depth first search, recursive function. And then the base case is clearly explained in the paragraph. And then recurrence formula is easy to work on.
Code execution
1. Line 20, int[] should be char[]. Return type is char[].
2. line 23, return char array, should be new char[]{'0'}, not "0".
3. line 28, do not change function argument. Declare a new variable.
4. line 25 - 30 should be written in the following:
var isNegative = n < 0;
var postiveOne = isNegative? -n : n;
two lines instead of six lines.
5. line 31, comment: "at least I have one edge case, continue later. need idea?"
Remove the comment!
6. line 37, for(;;), use while(true)
7. line 39, digitOne variable should be rightMost.
8. line 48, 49, move at the beginning, emphasis that it is the base case.
if( loopInt < 10)
{
}
Overall, the code is not structured very well. The code should be self-documented. And the code is written as an iterative solution, but recursive function should be quick and easy solution to write. I was not a very good programmer back in 2013, I have to face the reality after the review of the code.
What happened after 2013?
Action items
In order to punish myself do not focus on learning basic mathematics in computer science, I decide to spend at least 5 hours to learn vocabulary in the book, at least collect five hundred words. And those words will be posted here.
This is the drill I learned when I watch China Open tennis professional players did, after they tried to hit Mercede sign, the athletes have to do push up because she/ he fails.
Tuesday, December 12, 2017
Binary search practice
Dec. 12, 2017
Binary search algorithm is getting easy to write and I wrote one more time on Dec. 11 10:00 PM mock interview. I wrote the algorithm using C# language and the code passes all test cases.
Here is C# code.
Line 50: return binarySearch(x, n start, end);
I forgot to write a recursive call as line 50 shows. After the whiteboard testing, I wrote the test case Root(7, 3) and then I found out the bug.
Dec. 19, 2017 10:14 PM
Binary search range should be discussed based on x value, if x > 1, then the search range is [0, x]. But if x < 1, then search range is [x, 1] instead.
The mock interview practice has a bug related to range to search.
Introduction
Binary search algorithm is getting easy to write and I wrote one more time on Dec. 11 10:00 PM mock interview. I wrote the algorithm using C# language and the code passes all test cases.
Code review
Here is C# code.
Line 50: return binarySearch(x, n start, end);
I forgot to write a recursive call as line 50 shows. After the whiteboard testing, I wrote the test case Root(7, 3) and then I found out the bug.
Follow up
Dec. 19, 2017 10:14 PMBinary search range should be discussed based on x value, if x > 1, then the search range is [0, x]. But if x < 1, then search range is [x, 1] instead.
The mock interview practice has a bug related to range to search.
Enumerable extension methods
Dec. 12, 2017
It is a good idea to invest time to memorize Enumerable extension methods. I like to go over each API first, and then start to read LINQ and prepare myself for next project.
Here is the link.
Introduction
It is a good idea to invest time to memorize Enumerable extension methods. I like to go over each API first, and then start to read LINQ and prepare myself for next project.
Here is the link.
Sunday, December 10, 2017
Binary search tree search from root to leaf node
Dec. 10, 2017
It is the great learning experience for me to do mock interview tonight at 10:00 PM. I met an architecture tonight, the peer showed me how to write correct code first, and then reminded me to write optimal code as well. The search in binary search tree can turn left and then turn right and then turn left, but invariant is that the path is from root to leaf node, and the answer is always found until the leaf node is reached.
I practiced this algorithm so many times, last time I wrote a blog about the experience one month ago. Here is the blog.
Today I solved the problem with the help of the peer.
There are two bounds to work on. One is the lower bound value which is smaller than given value, and then the other one is upper bound which is smaller than given value. In order to find the upper bound, we are looking for the first value which is bigger than given value first, and then find a smaller value until one is found. Then we are sure that we are find the upper bound value.
In my previous practices, the upper bound value should be searched in two directions, go right to find bigger value, and then go left to find smaller value.
Feedback is encouraging
Dec. 13 ,2017
Finally I have time to come out a test case to illustrate the search, and the steps are left and right and left and right and left.
Here is the binary search tree, given value 7, the largest smaller BST key should be 6. How to find the node with value 6?
Start from root node with value 10, and then visit every node in the above tree, and visit the leaf node with value 6, and the answer is 6.
Introduction
Code study
Today I solved the problem with the help of the peer.
There are two bounds to work on. One is the lower bound value which is smaller than given value, and then the other one is upper bound which is smaller than given value. In order to find the upper bound, we are looking for the first value which is bigger than given value first, and then find a smaller value until one is found. Then we are sure that we are find the upper bound value.
In my previous practices, the upper bound value should be searched in two directions, go right to find bigger value, and then go left to find smaller value.
Feedback is encouraging
Follow up
Dec. 13 ,2017
Finally I have time to come out a test case to illustrate the search, and the steps are left and right and left and right and left.
Here is the binary search tree, given value 7, the largest smaller BST key should be 6. How to find the node with value 6?
Start from root node with value 10, and then visit every node in the above tree, and visit the leaf node with value 6, and the answer is 6.
Code Review: Learn Trie from Leetcode 212
Dec. 10, 2017
I posted a question on code review today, it is called Learn Trie from Leetcode 212. I got a comment to read patricia trie for space complexity, so I spent 30 minutes to read about it.
Here is one article I like to read, the link is Compressing Radix Tress Without Tears.
Introduction
I posted a question on code review today, it is called Learn Trie from Leetcode 212. I got a comment to read patricia trie for space complexity, so I spent 30 minutes to read about it.
30 minutes reading
Here is one article I like to read, the link is Compressing Radix Tress Without Tears.
Mother Tesesa
Dec. 10, 2017
I always feel good to stay humble and make a living, struggling is good, learning is fun and life is also great without good wealth or health. My sister has never heard about Teresa before. So I also need to study more about mother Teresa, and hopefully I can be more educated and be confident to be myself.
Here is 19 minutes talk given by Mother Teresa, Acceptance Speech by Mother Teresa Media Player at Nobel prize org. I remembered that in Florida one time my friend in church shared me her story, talking about people can not afford a pair of shoes.
Introduction
Mother Teresa is the favorite character I know as a Christian. And I use her story to help myself to communicate with my sister back in China as well. Since we dispute on the immigration issue, do I make right choice to sponsor my nephew to immigrate to Canada? She insists that China is best place to develop a career and life, now it is not 20 or 30 years ago, young people choose to stay in China instead of immigration to United States or Canada. I think that Canada has best education system in the world, and also the young people have their own rights to make their own decisions.
I share my argument with my sister, life is not about money, how many income to have, how good the career you have. My role model is Mother Teresa, I do not want to compare myself to my sister or other classmates.I always feel good to stay humble and make a living, struggling is good, learning is fun and life is also great without good wealth or health. My sister has never heard about Teresa before. So I also need to study more about mother Teresa, and hopefully I can be more educated and be confident to be myself.
Video talk
Here is 19 minutes talk given by Mother Teresa, Acceptance Speech by Mother Teresa Media Player at Nobel prize org. I remembered that in Florida one time my friend in church shared me her story, talking about people can not afford a pair of shoes.
Saturday, December 9, 2017
Mock interview weekday 10:00 PM
Dec. 9, 2017
It is the question a young graduate student asked me in mock interview recently, what is my motivation to practice mock interview? Am I preparing for interview or just for training and improving skills.
I did write a blog on this topic before. It was more than four months ago. The link is here. The topic is to do your current job well. We have to learn how to serve the current employer very well. A lot of uncertain things will happen in the job, we have no control at all. But we can choose to do thing easy to be controllable, keep practice mock interview, keep meeting highly talented programmers, keep practice those thirty algorithms again and again on mock platform, learn one thing a time, practice one algorithm a time, learn from one peer at a time.
In order to get really good on one algorithm, I also ask the question on code review stack exchange to get more input from the general public.
Training is like favorite sports I like, tennis. I learn from professional tennis players, follow them on instagram every day. The top tennis professional players are very good to market themselves, educate the fans what is really a sports professional, I just learn how to do interval training from 詹詠然 Latisha Chan , problem solving skills. My favorite players are Alize Cornet, Elena Vesnina, 詹詠然 Latisha Chan.
We know that the algorithm and data structure plays so important role as a software programmer. We also know how the technology makes our life so enjoyable and so rich. We actually change the world through our daily work as software programmer. We have to train ourselves like professional tennis sports players do. To expedite daily problem solving, write highly self-documented code, and keep updated with latest trends in education, technology and hottest market - competitive career and job search, one of training I choose to do is to practice mock interview daily at 10:00 PM. Keep working on crafting skills, communication skills, whiteboard skills, the rest will come naturally.
Through those hundred mock interviews, I learn to work on the same mock interview algorithm again and again. I actually train myself to learn various things, coding style, testing, and also new features in language, a new language, how to help and communicate, experience tough time, deal with tough situation. I document all the experience through coding blogs.
I used to write so complicated code, and worry about bugs. Every time I make code change I worry about all kinds of issues. One time I remembered that I may mess up existing code in the same function, for example, the function I have to work on is too complicated and it will take some time to rewrite and test them. Right now, I understand that it is more important to write with good coding style, good code principle instead of just making it work, I kill the code right away and start to write clean code. Zero tolerance on bad coding style, zero tolerance violation of coding principles like DRY, SRP, S.O.L.I.D., TED principle.
Introduction
It is the question a young graduate student asked me in mock interview recently, what is my motivation to practice mock interview? Am I preparing for interview or just for training and improving skills.
My story
In order to get really good on one algorithm, I also ask the question on code review stack exchange to get more input from the general public.
Training is like favorite sports I like, tennis. I learn from professional tennis players, follow them on instagram every day. The top tennis professional players are very good to market themselves, educate the fans what is really a sports professional, I just learn how to do interval training from 詹詠然 Latisha Chan , problem solving skills. My favorite players are Alize Cornet, Elena Vesnina, 詹詠然 Latisha Chan.
We know that the algorithm and data structure plays so important role as a software programmer. We also know how the technology makes our life so enjoyable and so rich. We actually change the world through our daily work as software programmer. We have to train ourselves like professional tennis sports players do. To expedite daily problem solving, write highly self-documented code, and keep updated with latest trends in education, technology and hottest market - competitive career and job search, one of training I choose to do is to practice mock interview daily at 10:00 PM. Keep working on crafting skills, communication skills, whiteboard skills, the rest will come naturally.
New story
I used to write so complicated code, and worry about bugs. Every time I make code change I worry about all kinds of issues. One time I remembered that I may mess up existing code in the same function, for example, the function I have to work on is too complicated and it will take some time to rewrite and test them. Right now, I understand that it is more important to write with good coding style, good code principle instead of just making it work, I kill the code right away and start to write clean code. Zero tolerance on bad coding style, zero tolerance violation of coding principles like DRY, SRP, S.O.L.I.D., TED principle.
Education of computer science
Dec. 9, 2017
It is normal 10:00 PM mock interview, but this is the first time I met a Chinese and also there was issue about audio through mock platform. I suggested to use skype phone number to get audio, instead the peer suggested to use Wechat to get audio. There are two algorithms involved, one is spiral matrix print for me, one is Sudoku solver for the peer. We talked about the algorithm and reviewed the code for one hour, and then we spent time to share the experience through wechat until 12:40 AM. It lasted 2 hours 40 minutes.
The peer wrote a Sudoku solve with a back tracking bug. I told the peer that Let me review the code and also help to find the bug.
I gave advice on coding style. Do not use i, j instead of using row and column.
Suggest to calculate the next row/ next column and express the intent to calculate.
Write first line of code in the function to discuss base case.
Remove if/ else and nested if/else, make the code flat, avoid smell of arrow-like code.
Most important is to discuss the backtracking and why it is so important to do it.
I enjoyed the discussion, I did see that people do not do backtracking and code still passes all test cases before. This time the backtracking has to be done, otherwise 5 out 7 test cases failed.
For example, Sudoku first row:
5 3 _ _ 7 _ _ _ _
For example, first _ can be filled with 9 possibility, from '1' to '9', for example, for example, '1' is tried, and then continue to second _ which is row 0 and column 3, '2' is put into trial. If '2' fails, then second _ with index of (0,3) should be backtracked to be filled '.'. We need to go back to the first _ to try next available number.
I showed the peer things to work on. Also I learned from the peer through his experience, he had 8 phone interviews for intern, 2 rounds of phone interview for interview, he definitely almost made it. Apple, Facebook, Uber and Microsoft.
All advice are from the code review on stackexchange.com, the question I posted over one month ago.
First document some facts about computer science graduate study and questions and answers:
1. It is hard to get in the computer science master degree program in Northwestern university. The tuition is expensive compared to Santa Clara university, $18,000/term vs $9,000/term.
2. To get a computer master degree, there are 45 credits in the program, non-thesis program. The tuition is around 45 thousand dollars, each credit costs $1,000 dollars. Private university, same tuition for international or noninternational.
3. Around 100 computer science master degree student, half are Chinese, half are Indian.
4. What is advantage of studying in Sillicon Valley?
5. How many of them get intern at Facebook or Apple? Compare to Waterloo university in Canada undergraduate program?
6. What is policy of work visa in USA? OPT or summer intern, 60 days limitation.
7. What is the like to work full time? Do you experience the tough algorithm similar to Leetcode algorithm?
8. What is difference between students with Leetcode practice and full-time programmers with same practice?
9. Rent fee in California, $800/ month for one room or $1100/month to share 2 bed/ two bath condo.
10. Teaching and learning in the university, what is difference? Santa Clara university vs Northwestern university.
11. What is my motivation to practice mock interview?
Introduction
Backtracking bug
The peer wrote a Sudoku solve with a back tracking bug. I told the peer that Let me review the code and also help to find the bug.
I gave advice on coding style. Do not use i, j instead of using row and column.
Suggest to calculate the next row/ next column and express the intent to calculate.
Write first line of code in the function to discuss base case.
Remove if/ else and nested if/else, make the code flat, avoid smell of arrow-like code.
Most important is to discuss the backtracking and why it is so important to do it.
I enjoyed the discussion, I did see that people do not do backtracking and code still passes all test cases before. This time the backtracking has to be done, otherwise 5 out 7 test cases failed.
For example, Sudoku first row:
5 3 _ _ 7 _ _ _ _
For example, first _ can be filled with 9 possibility, from '1' to '9', for example, for example, '1' is tried, and then continue to second _ which is row 0 and column 3, '2' is put into trial. If '2' fails, then second _ with index of (0,3) should be backtracked to be filled '.'. We need to go back to the first _ to try next available number.
I showed the peer things to work on. Also I learned from the peer through his experience, he had 8 phone interviews for intern, 2 rounds of phone interview for interview, he definitely almost made it. Apple, Facebook, Uber and Microsoft.
All advice are from the code review on stackexchange.com, the question I posted over one month ago.
Talk of graduate study
1. It is hard to get in the computer science master degree program in Northwestern university. The tuition is expensive compared to Santa Clara university, $18,000/term vs $9,000/term.
2. To get a computer master degree, there are 45 credits in the program, non-thesis program. The tuition is around 45 thousand dollars, each credit costs $1,000 dollars. Private university, same tuition for international or noninternational.
3. Around 100 computer science master degree student, half are Chinese, half are Indian.
4. What is advantage of studying in Sillicon Valley?
5. How many of them get intern at Facebook or Apple? Compare to Waterloo university in Canada undergraduate program?
6. What is policy of work visa in USA? OPT or summer intern, 60 days limitation.
7. What is the like to work full time? Do you experience the tough algorithm similar to Leetcode algorithm?
8. What is difference between students with Leetcode practice and full-time programmers with same practice?
9. Rent fee in California, $800/ month for one room or $1100/month to share 2 bed/ two bath condo.
10. Teaching and learning in the university, what is difference? Santa Clara university vs Northwestern university.
11. What is my motivation to practice mock interview?
Suits TV show money talk
Dec. 9, 2017
It is time for me to look up the pay of Suits TV show. I read the article this morning. The article is here: Cast Of ‘Suits’: How Much Are They Worth?
Thursday, December 7, 2017
Binary search algorithm is very classical
Dec. 7, 2017
It is learning process to practice mock interview. So many things are not under control. For example, today I attended 10:00 PM mock interview, time passed and I was matched with one after five minutes passed by. The peer said that the laptop has camera and audio issue, if I like to stop then I can do that. I offered my cellular phone number to make a phone call to get audio at least. And then the peer joined with audio on.
Binary search is such a challenging algorithm, I observed how the peer wrote code but somehow I did not take my opportunity to step in, gave the peer some hint to put the peer back in track.
Here is the evaluation I got. I need to work on communication.
I need to learn how to take mock interview seriously, no matter what happens at the beginning. Treat the peer like my customer. I have to show the peer how good I can solve binary search algorithm, it is give and take, win win solution. My best solution is here, I just got it after more than three practice. It does not matter the array is ascending order or not, I will get rid of half of array in my search each step. That is showing my attitude, head on to solve the problem.
Do not hold grudges. I still remembered that I waste hours to try to simplify the algorithm recently. Here is the blog about my last practice.
It is good practice to review some bible verse before or after mock interview. Today I like to choose this bible verse help me to improve. Also I like to take chance to learn a few words. This bible verse is hard to remember word by word. I will give it a try next few days.
anger
bitterness
clamor (?)
forgiving
kind
malice
slander (?)
tenderhearted
wrath (?)
Remember Chinese version first:
Introduction
It is learning process to practice mock interview. So many things are not under control. For example, today I attended 10:00 PM mock interview, time passed and I was matched with one after five minutes passed by. The peer said that the laptop has camera and audio issue, if I like to stop then I can do that. I offered my cellular phone number to make a phone call to get audio at least. And then the peer joined with audio on.
Binary search is such a challenging algorithm, I observed how the peer wrote code but somehow I did not take my opportunity to step in, gave the peer some hint to put the peer back in track.
Feedback
Here is the evaluation I got. I need to work on communication.
I need to learn how to take mock interview seriously, no matter what happens at the beginning. Treat the peer like my customer. I have to show the peer how good I can solve binary search algorithm, it is give and take, win win solution. My best solution is here, I just got it after more than three practice. It does not matter the array is ascending order or not, I will get rid of half of array in my search each step. That is showing my attitude, head on to solve the problem.
Do not hold grudges. I still remembered that I waste hours to try to simplify the algorithm recently. Here is the blog about my last practice.
One bible verse to help
Ephesians 4:31-32 ESV / 694 helpful votes
Let all bitterness and wrath and anger and clamor and slander be put away from you, along with all malice. Be kind to one another, tenderhearted, forgiving one another, as God in Christ forgave you.
anger
bitterness
clamor (?)
forgiving
kind
malice
slander (?)
tenderhearted
wrath (?)
Remember Chinese version first:
以弗所书 4:31-32Chinese Contemporary Bible (Simplified) (CCB)
31 要从你们当中除掉一切的苦毒、恼恨、怒气、争吵、毁谤和邪恶。 32 总要以恩慈、怜悯的心彼此相待,要互相饶恕,正如上帝在基督里饶恕了你们一样。
Binary search tree practice
Dec. 7, 2017
Binary search tree definitely is my most favorite data structure this year 2017. I had written more than 20 times through mock interviews and also observe how peers perform on the tree a lot of times. I never learn a data structure with such rich experience, go through so many emotions. Every time I work on the binary search tree, I think that it is such a fun activity to do.
My C# code to write a binary search tree successor is here. It is the first time I had chance to write a test case to test my code in mock interview as well.
Introduction
Binary search tree definitely is my most favorite data structure this year 2017. I had written more than 20 times through mock interviews and also observe how peers perform on the tree a lot of times. I never learn a data structure with such rich experience, go through so many emotions. Every time I work on the binary search tree, I think that it is such a fun activity to do.
My practice
My C# code to write a binary search tree successor is here. It is the first time I had chance to write a test case to test my code in mock interview as well.
Life was so beautiful
Dec. 7, 2017
I spent more than one hour to go over pictures I took with friends in Vancouver back to 2012, and then went back to 2008 in Orlando, 2010 in Texas Austin, life was so beautiful because I had some friends to go out together.
At top of mountain Bonnell in Austin, Texas, 16 days road trip from Florida to Vancouver, Canada. I visited so many national parks in United States. It was kind of so interesting to experience difference of landscapes of United States in such a short time.
Introduction
I spent more than one hour to go over pictures I took with friends in Vancouver back to 2012, and then went back to 2008 in Orlando, 2010 in Texas Austin, life was so beautiful because I had some friends to go out together.
At top of mountain Bonnell in Austin, Texas, 16 days road trip from Florida to Vancouver, Canada. I visited so many national parks in United States. It was kind of so interesting to experience difference of landscapes of United States in such a short time.
Wednesday, December 6, 2017
Leetcode 393: UTF-8 Validation
Dec. 6, 2017
The algorithm is to determine if the integer array has specified format with one to 4 byte data. I found out that best way to deal with nervousness is to read the problem statement again and again, more than four times. And then usually I understand the algorithm and bring back my confidence about bit manipulation problem solving. The problem statement is here.
It is time for me to review my practice of bit manipulation by looking up the blog using keyword: bit manipulation. The search result is here.
Review some basics from one of blogs.
Top coder - fun with bits, the article link is here.
Take some notes:
Use bits of an integer to represent a set. Not only does it produce an order-of-magnitude improvement in both speed and size, it can often simplify code at the same time.
Go over the most popular set manipulations in the following:
Set union
A | B
Set intersection
A & B
Set subtraction
A & ~B
Set negation
ALL_BITS ^ A
Set bit
A |= 1 << bit
Clear bit
A &= ~(1 << bit)
Test bit
(A & 1 << bit) != 0
Extracting every last bit
Counting out the bits
It is time for Julia to learn bit manipulation again. What Julia likes to do is to read the article word by word and then spend 10 - 20 minutes to go over the terms and warm up the idea how to solve the problem to use integer to represent a set.
It is not so often Julia uses this technique at work, but it is easy to review again and get the idea.
Dec.16, 2017
I asked my mock interview partner to work on this algorithm together, and then we had some discussion. Here are the notes.
The input from the peer:
32 - Each integer has 32 bits
%256 - how to extract rightmost 8 bits?
/256 - move to next 8 bits
>>=8 - or right shift 8 bits
int = int[4] - one integer uses 4 integer
0****** < 128 - check the range
110**** >= 11000000 < 111000000
1110**** >= 11100000 < 11110000
11110*** >- 11110000 < 11111000
10****** >= 10000000 < 11000000
Julia's input:
- integer - bit mask
set 8 bit - use an integer to represent a set, each integer 8 bits express different numbers
Set bit
A |= 1 << bit
Clear bit
A &= ~(1 << bit)
Test bit
(A & 1 << bit) != 0
Extracting every last bit
Counting out the bits
Apply the bit technique to current case:
test case 1 : (arr[i] & 1 << 7) == 0 - 0xxxxxxx - figure out the leftmost bit is 0.
test case 2: arr[i] >> 5 ^ 6 = 0, judge 110xxxxx 10xxxxxx, there are four operations:
AND, OR, negative, XOR ->
The peer came out the idea to shift the first 8 bits to left 5 bits, and then XOR 110, it should be 0.
Reference:
Top coder article about bit manipulation. The link is here.
I worked with a peer with strong math and engineering background, the peer works hard; if I share some tips, the peer will come out the solution in less than 5 minutes.
Introduction
Code review
It is time for me to review my practice of bit manipulation by looking up the blog using keyword: bit manipulation. The search result is here.
Review some basics from one of blogs.
Top coder - fun with bits, the article link is here.
Take some notes:
Use bits of an integer to represent a set. Not only does it produce an order-of-magnitude improvement in both speed and size, it can often simplify code at the same time.
Go over the most popular set manipulations in the following:
Set union
A | B
Set intersection
A & B
Set subtraction
A & ~B
Set negation
ALL_BITS ^ A
Set bit
A |= 1 << bit
Clear bit
A &= ~(1 << bit)
Test bit
(A & 1 << bit) != 0
Extracting every last bit
Counting out the bits
It is time for Julia to learn bit manipulation again. What Julia likes to do is to read the article word by word and then spend 10 - 20 minutes to go over the terms and warm up the idea how to solve the problem to use integer to represent a set.
It is not so often Julia uses this technique at work, but it is easy to review again and get the idea.
Follow up
Dec.16, 2017
I asked my mock interview partner to work on this algorithm together, and then we had some discussion. Here are the notes.
The input from the peer:
32 - Each integer has 32 bits
%256 - how to extract rightmost 8 bits?
/256 - move to next 8 bits
>>=8 - or right shift 8 bits
int = int[4] - one integer uses 4 integer
0****** < 128 - check the range
110**** >= 11000000 < 111000000
1110**** >= 11100000 < 11110000
11110*** >- 11110000 < 11111000
10****** >= 10000000 < 11000000
Julia's input:
- integer - bit mask
set 8 bit - use an integer to represent a set, each integer 8 bits express different numbers
Set bit
A |= 1 << bit
Clear bit
A &= ~(1 << bit)
Test bit
(A & 1 << bit) != 0
Extracting every last bit
Counting out the bits
Apply the bit technique to current case:
test case 1 : (arr[i] & 1 << 7) == 0 - 0xxxxxxx - figure out the leftmost bit is 0.
test case 2: arr[i] >> 5 ^ 6 = 0, judge 110xxxxx 10xxxxxx, there are four operations:
AND, OR, negative, XOR ->
The peer came out the idea to shift the first 8 bits to left 5 bits, and then XOR 110, it should be 0.
Reference:
Top coder article about bit manipulation. The link is here.
Editorial notes:
I worked with a peer with strong math and engineering background, the peer works hard; if I share some tips, the peer will come out the solution in less than 5 minutes.
Tuesday, December 5, 2017
Leetcode 37: Sudoku Solver
Dec. 5, 2017
It is the classical depth first algorithm called Sudoku solver. I had great time to practice mock interview and completed the code and passed all test cases in 28 minutes. The peer was very helpful, and I was told that there is a bug on line 29 and missing a function argument on line 58 after I did whiteboard testing.
Here is C# code.
Dec. 6, 2017
Two more comments after mock interview, one is to understand C# keyword const and static, and second one is to think carefully about const variable meaningful name.
I wrote line 5 public static const int SIZE = 8; in mock interview, compile error, so I quickly removed const keyword in the mock interview. Need to look into the const in C# again.
Later I learned that const is static automatically, but static can be modified, not readonly. So I should write line 5 like the following:
public static readonly int SIZE = 8;
or
public const int SIZE = 8;
It is good to name a variable using meaningful one. Let us discuss more here.
Board is 9 * 9 matrix, I added = sign after < on line 9 to make line 9 in the following:
board.GetLength(0) <= SIZE
better saying
board.GetLength(0) <= LASTCOLUMN
When I did whiteboard testing, I added equal = sign.The matrix's SIZE is 9, and LASTCOLUMN = 8. So the variable name on line 5 should
better be called LASTCOLUMN = 8
Line 5: public static int LASTCOLUMN = 8.
1. Read C# Keywords/Modifiers/Access Modifiers/const, the link is here. There are around 12 access modifiers, plan to read one by one. Abstract, async, const, event, extern, in, out, override, readonly, sealed, static, unsafe, virtual, volatile.
2. C# static vs const on stackoverflow, link is here.
Plan to read 10 minutes on this discussion:
Argument or facts:
It is interesting to note that const members are always static, whereas a readonly member can be either static or not, just like a regular field.
3. One more thing is to review code review website the algorithm I asked about Sudoku solver, and understand the code review about complaints about const value 8 or 9 all over the code.
The code review is called Sudoku solver recursive solution with clear structure, I posted it 30 days ago.
Introduction
It is the classical depth first algorithm called Sudoku solver. I had great time to practice mock interview and completed the code and passed all test cases in 28 minutes. The peer was very helpful, and I was told that there is a bug on line 29 and missing a function argument on line 58 after I did whiteboard testing.
Here is C# code.
Dec. 6, 2017
Two more comments after mock interview, one is to understand C# keyword const and static, and second one is to think carefully about const variable meaningful name.
Static vs Const
I wrote line 5 public static const int SIZE = 8; in mock interview, compile error, so I quickly removed const keyword in the mock interview. Need to look into the const in C# again.
Later I learned that const is static automatically, but static can be modified, not readonly. So I should write line 5 like the following:
public static readonly int SIZE = 8;
or
public const int SIZE = 8;
SIZE or LASTCOLUMN
Board is 9 * 9 matrix, I added = sign after < on line 9 to make line 9 in the following:
board.GetLength(0) <= SIZE
better saying
board.GetLength(0) <= LASTCOLUMN
When I did whiteboard testing, I added equal = sign.The matrix's SIZE is 9, and LASTCOLUMN = 8. So the variable name on line 5 should
better be called LASTCOLUMN = 8
Line 5: public static int LASTCOLUMN = 8.
Actionable Items
1. Read C# Keywords/Modifiers/Access Modifiers/const, the link is here. There are around 12 access modifiers, plan to read one by one. Abstract, async, const, event, extern, in, out, override, readonly, sealed, static, unsafe, virtual, volatile.
2. C# static vs const on stackoverflow, link is here.
Plan to read 10 minutes on this discussion:
Argument or facts:
It is interesting to note that const members are always static, whereas a readonly member can be either static or not, just like a regular field.
The code review is called Sudoku solver recursive solution with clear structure, I posted it 30 days ago.
Yesterday once more Julia version
Dec. 5, 2017
It is the learning experience to be a daughter back to 2014, my mom started her journey to welcome her dementia, she started to experience dementia symptom very early stage in daily life, prepared to live as a dementia senior with full time care, five daughters one son will help her to overcome the difficult time. One of my sisters was full time physician and took care my mom as a doctor does.
Related to learning experience, I had to watch my mom to memorize all her five daughters and one son's name, she said each of us name correct, and ask me if she did ok in 2014 Chinese spring festival while I was on vacation in the city of Yichun. My doctor sister gave her prescription to calm her down, otherwise she talked whole night face to ceiling lying on bed, talk all poems and songs she memorized in her 20s, 30s, I never heard before, it is correct and nice poem to document herself as very nice young person. And then she watched the TV, and told me that the character is her nephew. I recorded the video and I may post on youtube.com one day to educate how tough the dementia is as a disease.
I went back to China to celebrate Chinese new year in 2014 with my mom and my sisters and brothers and families, I planned very well for a road trip from Shanghai to Yichun, stopping by Wu Xi to visit lake of Tai, and teng wang tower in the city of Nanchang. Still remember that I learned something from the work, I bought same tennis shoes from size 6 to size 11, 5 pairs for my five siblings, and one pair for my nephew, I went to USA Bellingham sports store and got those shoes.
I like to dress red leather Jacket, so I had great pictures with my family. I had a road trip to cross the country over 1000 KM in less than 2 days. I visited the famous tower in the city of Nanchang.
Here are the pictures, all best memory are back when I revisit the pictures. My mom, my sister-in-law, my sister's granddaughter (my granddaughter).
Introduction
It is the learning experience to be a daughter back to 2014, my mom started her journey to welcome her dementia, she started to experience dementia symptom very early stage in daily life, prepared to live as a dementia senior with full time care, five daughters one son will help her to overcome the difficult time. One of my sisters was full time physician and took care my mom as a doctor does.
Related to learning experience, I had to watch my mom to memorize all her five daughters and one son's name, she said each of us name correct, and ask me if she did ok in 2014 Chinese spring festival while I was on vacation in the city of Yichun. My doctor sister gave her prescription to calm her down, otherwise she talked whole night face to ceiling lying on bed, talk all poems and songs she memorized in her 20s, 30s, I never heard before, it is correct and nice poem to document herself as very nice young person. And then she watched the TV, and told me that the character is her nephew. I recorded the video and I may post on youtube.com one day to educate how tough the dementia is as a disease.
I went back to China to celebrate Chinese new year in 2014 with my mom and my sisters and brothers and families, I planned very well for a road trip from Shanghai to Yichun, stopping by Wu Xi to visit lake of Tai, and teng wang tower in the city of Nanchang. Still remember that I learned something from the work, I bought same tennis shoes from size 6 to size 11, 5 pairs for my five siblings, and one pair for my nephew, I went to USA Bellingham sports store and got those shoes.
I like to dress red leather Jacket, so I had great pictures with my family. I had a road trip to cross the country over 1000 KM in less than 2 days. I visited the famous tower in the city of Nanchang.
Here are the pictures, all best memory are back when I revisit the pictures. My mom, my sister-in-law, my sister's granddaughter (my granddaughter).
Monday, December 4, 2017
My favorite verse: Proverbs 28:22
Dec. 4, 2017
It is the drill I use to relax, kick out worries by memorizing a favorite bible verse. I have some thoughts about my finance future today, so I like to choose a bible verse about money.
Today I like to memorize the verse in English. Proverbs 28:22, The stingy are eager to get rich and are unaware that poverty awaits them.
箴言28章22节说:“人有恶眼想要急速发财,却不知穷乏必临到他身。”
What I do is to read the verse loud at least three times, repeat the word by word, and try to memorize.
Introduction
It is the drill I use to relax, kick out worries by memorizing a favorite bible verse. I have some thoughts about my finance future today, so I like to choose a bible verse about money.
Today I like to memorize the verse in English. Proverbs 28:22, The stingy are eager to get rich and are unaware that poverty awaits them.
箴言28章22节说:“人有恶眼想要急速发财,却不知穷乏必临到他身。”
What I do is to read the verse loud at least three times, repeat the word by word, and try to memorize.
Julia's Handwriting
More Effective LINQ
Dec. 4, 2017
Plan to look into 4 hours course called More Effective LINQ on pluralsight.com.
Now it is 10:27 PM, next 20 minutes I will learn the basics of the course, Discovering the Power of LINQ.
Introduction
Now it is 10:27 PM, next 20 minutes I will learn the basics of the course, Discovering the Power of LINQ.
Code review: Leetcode 56: Merge Intervals
Dec. 4, 2017
Plan to review code review: Leetcode 56: Merge Intervals. I like to write C# code based on every review I got.
Review 1: here is the link.
Review 2: here is the link.
Code review: LINQ and string.Split do it yourself practice
Dec. 4, 2017
Introduction
It is my favorite algorithm called LINQ and string.Split do it yourself practice. I asked the question over 8 months ago. On Dec. 3, 2017, I had chance to write similar algorithm using C#, and I like to practice the algorithm and write the code after the mock interview.
Case Study: What if IIS runs out disk space
Dec. 4, 2017
I like to write a blog about the case study: What if IIS runs out disk space? It is a good topic for me to learn how system is designed as an internet information server.
Plan to learn and write down what I have learned through my study.
How to prepare for IIS diskspace error?
Service unavabile -
WWW service stop, virtual disk space service stopped working, logical disk space stopping working
2 weeks before the day to show service unaviable, every day the error showed up about unable to write log file.
Event system view:
Event ID: 1011, 1002, 15002, 7036, 4
Introduction
I like to write a blog about the case study: What if IIS runs out disk space? It is a good topic for me to learn how system is designed as an internet information server.
Plan to learn and write down what I have learned through my study.
Case Study
How to prepare for IIS diskspace error?
Service unavabile -
WWW service stop, virtual disk space service stopped working, logical disk space stopping working
2 weeks before the day to show service unaviable, every day the error showed up about unable to write log file.
Event system view:
Event ID: 1011, 1002, 15002, 7036, 4
Sunday, December 3, 2017
Codefight recommendation
Dec, 3, 2017
It is so good to meet a peer who likes to share her experience with career conversion plan, went through outco.io bootcamp and also coding camp.
Here are some recommendation I got from my peer today through mock interview.
https://codefights.com/
https://interviewing.io/
https://www.freecodecamp.org
girldevelopit.org
Learning is so much fun with people sharing their own experience. Julia learned so many things through hours discussion.
Introduction
Here are some recommendation I got from my peer today through mock interview.
https://codefights.com/
https://interviewing.io/
https://www.freecodecamp.org
girldevelopit.org
Learning is so much fun with people sharing their own experience. Julia learned so many things through hours discussion.
Best learning experience is to help the peer to succeed
Dec. 3, 2017
It is the traditional two pointers technique, sliding window, with tough situation to handle left pointer to shorten the substring.
Two programmers were working together this Sunday morning 10:00 AM. The algorithm was written with discussion of the algorithm first with two test cases. And the code was examined carefully by the peer using whiteboard testing, and also platform Run test cases gave failed test case information.
Here is Java code to study.
I almost forgot to write what I did to help the peer, I asked one question before the peer liked to write code. A test case ['a','b','c'], string is "aaefbcgaxy", and the minimum substring is "bcga".
Another thing Julia did is to look up Java HashMap get API, and reminded that if the key is not in HashMap, get API will return null pointer.
Introduction
It is the traditional two pointers technique, sliding window, with tough situation to handle left pointer to shorten the substring.
Two programmers were working together this Sunday morning 10:00 AM. The algorithm was written with discussion of the algorithm first with two test cases. And the code was examined carefully by the peer using whiteboard testing, and also platform Run test cases gave failed test case information.
Java code to study
I almost forgot to write what I did to help the peer, I asked one question before the peer liked to write code. A test case ['a','b','c'], string is "aaefbcgaxy", and the minimum substring is "bcga".
Another thing Julia did is to look up Java HashMap get API, and reminded that if the key is not in HashMap, get API will return null pointer.
How to find smallest number?
Dec. 3, 2017
It is 30 minutes and then I start to learn what I put into those 30 minutes to show what I can solve the algorithm. This is the smallest number to solve and it is kind of good one to demo the algorithm space and time analysis trade-off.
Here is the C# code. I did whiteboard testing, and then I could not spot the bug missing a break statement, I added line 43. The code had a bug related to index-out-of-range error, so I add else if statement from line 26 to 29. The peer was very patient and gave me the test case to point it out.
Introduction
It is 30 minutes and then I start to learn what I put into those 30 minutes to show what I can solve the algorithm. This is the smallest number to solve and it is kind of good one to demo the algorithm space and time analysis trade-off.
Code study
Here is the C# code. I did whiteboard testing, and then I could not spot the bug missing a break statement, I added line 43. The code had a bug related to index-out-of-range error, so I add else if statement from line 26 to 29. The peer was very patient and gave me the test case to point it out.
a Suits US TV series fan
Dec. 3, 2017
Suits is the most popular show I spent to watch each episode before. Here is the link. Plan to watch the video Meghan Markle & Patrick J. Adams on Suits. The video link is here. I like to learn how actors are working on their career and deal with low pay job very well, build up a success story at the end.
It is the normal Sunday morning, I went to bed around 3 AM, and got up around 8:30 AM. I need to open the window to get fresh air. So I wonder what I should do next. I cancelled 12:00 PM mock interview, just keep 10:00 AM mock interview. I like to go to Willingdon church. I spent 5 minutes on Netflix and then thought about pluralsight.com. But I decided to study 20 minutes interview for actor and actress of Suits, Meghan Markle & Patrick J. Adams on Suits. The video link is here.
I plan to go to swimming before 5 PM. And I added one schedule of mock interview at 10:00 PM.
Introduction
It is the normal Sunday morning, I went to bed around 3 AM, and got up around 8:30 AM. I need to open the window to get fresh air. So I wonder what I should do next. I cancelled 12:00 PM mock interview, just keep 10:00 AM mock interview. I like to go to Willingdon church. I spent 5 minutes on Netflix and then thought about pluralsight.com. But I decided to study 20 minutes interview for actor and actress of Suits, Meghan Markle & Patrick J. Adams on Suits. The video link is here.
I plan to go to swimming before 5 PM. And I added one schedule of mock interview at 10:00 PM.
Saturday, December 2, 2017
code review: Find the smallest substring that contains some given subset of characters
Dec. 2, 2017
The sliding window algorithm is very challenge one even after I posted Find the smallest substring that contains some given subset of characters two months ago. Today 12 PM I had a mock interview and then I have to work on the similar algorithm with a peer from the United Kingdom. With the peer's help, I spent 50 minutes to go over the analysis and coding but still could not finish the algorithm writing, we had a chat about how to work on algorithm after we worked on both interviews 80 minutes. The peer asked a break, we took 20 minutes break to chat about algorithms. In last 5 minutes, I was asked by peer to finish the algorithm. I almost finished but timeout, time limit is 110 minutes. The fact is that I lost my writing on the platform.
I need to recall what I did about the coding, and then post the algorithm here. The peer had good advice for me to write the algorithm this time, the code will be different from the one I wrote before.
Now it is Dec. 3, 12:09 AM. This version of code passes 2 test cases, fail 5 test cases. The C# code is here.
There are two issues in the code, first the input ["A"], search string "B", the result should be empty, not "B". Second issue is "Index was outside the bound of the array".
Continue to work on the bug fixing.
Now it is 12:35 AM. I fixed all the bugs. The function's arguments are not meaningful, so I mixed them together, one is arr, one is str. There are more than four places I mixed them in C# code here, line 26, arr[index] should be str[index], same as line 45, line 47. I changed them to meaningful name using char[] source, string search.
Lesson learned: Always use meaningful name. Express the intent. I should change the variable's name to avoid the errors at the very beginning.
The C# code is here to look up.
Line 58
var isNeeded = dictionary[visit] > 0;
Actually I wrote first like this:
var isNeeded = Array.IndexOf(arr, visit);
And the peer asked me the time complexity of Array.IndexOf, it is O(m) and m is the length of the arr length. I should make it O(1) time instead. The peer worked very hard to help me, he followed my analysis of algorithm, time complexity O(n) where n is the length of search string instead of O(mn).
And the bugs are fixed to make the changes on the following lines.
Line 65 - add dictionary.ContainsKey(current) to avoid run time exception. The peer told me to move line 77 - 85 inside the while loop starting from 58 to 88, to make the code more simple to write.
Julia wrote the code in mock interview, she is still learning how to write LINQ statement. She memorized the tip she got from the code review.
var dictionary = arr.ToDictionary<char, int>();
And the peer was confused, and asked what I was writing. So, I wrote a for statement instead right away. I did not know that I have to write two mapping for key and value using LINQ statement in mock interview.
The LINQ learning is challenging, I should write
var dictionary = arr.ToDictionary(c => c, c => 1);
It is the first time Julia learned that how good a peer can perform on the recursive algorithm, specially how to compose the test case quickly with the art of simplicity, and followed with the code.
Julia also learned that a programmer from other side of earth, North Ireland. Julia thought that the peer must work for Nokia before, but it ended up that Finland is far away from North Ireland. The peer corrected Julia on this.
The peer praised that Julia did very well on analysis of the algorithm, best one in last 5 or 6 peers worked on the algorithm. Julia gave honest response. It is all about hard work. Here is the code review about the algorithm on stackexchange.com, Julia worked on the algorithm over 2 weeks in 2015, and then she practiced mock interview on the algorithm over and over again. Here is the blog about over 5 or 6 mock interviews on the algorithm wrote in April 9, 2017.
Julia later looked up the university of North Ireland, Queen's University Belfast and talked to her roommate about Great Britain, compared to University of Victoria.
Introduction
The sliding window algorithm is very challenge one even after I posted Find the smallest substring that contains some given subset of characters two months ago. Today 12 PM I had a mock interview and then I have to work on the similar algorithm with a peer from the United Kingdom. With the peer's help, I spent 50 minutes to go over the analysis and coding but still could not finish the algorithm writing, we had a chat about how to work on algorithm after we worked on both interviews 80 minutes. The peer asked a break, we took 20 minutes break to chat about algorithms. In last 5 minutes, I was asked by peer to finish the algorithm. I almost finished but timeout, time limit is 110 minutes. The fact is that I lost my writing on the platform.
I need to recall what I did about the coding, and then post the algorithm here. The peer had good advice for me to write the algorithm this time, the code will be different from the one I wrote before.
Coding
There are two issues in the code, first the input ["A"], search string "B", the result should be empty, not "B". Second issue is "Index was outside the bound of the array".
Continue to work on the bug fixing.
Now it is 12:35 AM. I fixed all the bugs. The function's arguments are not meaningful, so I mixed them together, one is arr, one is str. There are more than four places I mixed them in C# code here, line 26, arr[index] should be str[index], same as line 45, line 47. I changed them to meaningful name using char[] source, string search.
Lesson learned
Lesson learned: Always use meaningful name. Express the intent. I should change the variable's name to avoid the errors at the very beginning.
The C# code is here to look up.
Line 58
var isNeeded = dictionary[visit] > 0;
Actually I wrote first like this:
var isNeeded = Array.IndexOf(arr, visit);
And the peer asked me the time complexity of Array.IndexOf, it is O(m) and m is the length of the arr length. I should make it O(1) time instead. The peer worked very hard to help me, he followed my analysis of algorithm, time complexity O(n) where n is the length of search string instead of O(mn).
And the bugs are fixed to make the changes on the following lines.
Line 65 - add dictionary.ContainsKey(current) to avoid run time exception. The peer told me to move line 77 - 85 inside the while loop starting from 58 to 88, to make the code more simple to write.
ToDictionary using LINQ
var dictionary = arr.ToDictionary<char, int>();
And the peer was confused, and asked what I was writing. So, I wrote a for statement instead right away. I did not know that I have to write two mapping for key and value using LINQ statement in mock interview.
The LINQ learning is challenging, I should write
var dictionary = arr.ToDictionary(c => c, c => 1);
Discussion between two peers
It is the first time Julia learned that how good a peer can perform on the recursive algorithm, specially how to compose the test case quickly with the art of simplicity, and follow
Julia also learned that a programmer from other side of earth, North Ireland. Julia thought that the peer must work for Nokia before, but it ended up that Finland is far away from North Ireland. The peer corrected Julia on this.
The peer praised that Julia did very well on analysis of the algorithm, best one in last 5 or 6 peers worked on the algorithm. Julia gave honest response. It is all about hard work. Here is the code review about the algorithm on stackexchange.com, Julia worked on the algorithm over 2 weeks in 2015, and then she practiced mock interview on the algorithm over and over again. Here is the blog about over 5 or 6 mock interviews on the algorithm wrote in April 9, 2017.
Julia later looked up the university of North Ireland, Queen's University Belfast and talked to her roommate about Great Britain, compared to University of Victoria.
Recursive function in python
Dec. 2, 2017
It is unbelievable that I met a super talent programmer from North Ireland, and it only took the peer less than 12 minutes to write a perfect solution. The mock platform only provides 4 PM, 6 PM, 8 PM three time slots for mock interview. I had 12 PM pacific time mock interview, and I met 8 PM United Kingdom time zone. Now, I know that I may meet programmers from United Kingdom in the weekend from 8 AM, 10 AM, 12 AM three time slots.
I just could not believe that the peer may be the best talent programmer I met so far. Here is the python code to study, first version and second version. I learned the python quickly, which looks like JavaScript.
Introduction
It is unbelievable that I met a super talent programmer from North Ireland, and it only took the peer less than 12 minutes to write a perfect solution. The mock platform only provides 4 PM, 6 PM, 8 PM three time slots for mock interview. I had 12 PM pacific time mock interview, and I met 8 PM United Kingdom time zone. Now, I know that I may meet programmers from United Kingdom in the weekend from 8 AM, 10 AM, 12 AM three time slots.
Code study
I just could not believe that the peer may be the best talent programmer I met so far. Here is the python code to study, first version and second version. I learned the python quickly, which looks like JavaScript.
Vancouver Housing Market Study
Dec. 2, 2017
Plan to read the article, Vancouver Foreign Buyer Ban? City May Limit Housing Market To Local Residents. The link is here.Study notes
Housing market research is new to me in English. I like to look up those words:
B
a foreign buyer Ban
builders
builders targeting investors, low interest rates, and favorable tax policies
C
City of Coucil
E
Excessive supply of global capital
F
Fuel by foreign and local speculation
M
numerous supply and demand measures
R
Restricting ownership of housing to local resident
Restricting short-term rentals
S
Vancouver's new 10-year housing strategy
Support of federal and provincial governments, particularly those around taxation
Facts provided in the article:
Home prices on Vancouver's upscale west side jumped 57 percent in the last three years, sending the typical price - including condos, townhouses and detached homes - to $1.4 million, according to the local real estate board.
In the Greater Vancouver region, the typical home now costs $1 million, 12.5 times the region's median household income of $79,930, putting home ownership out of reach of many residents.
To be a good tutor
Dec. 2, 2017
Introduction
It is such a challenge job to work on mock interview this morning 10:00 AM. The peer lost connections a few times, and also the peer asked me to help to write Java code. I played the role and the code is kind of ugly, but it served the purpose to show how to use recursive call. The connection was still broken, now it is 10:53 AM, the peer could not get back after 10 minutes. I HAVE to stop.
I finished the Java code and passed all test cases.
Here is Java code I helped to complete.
How Far I Can Go
To learn an algorithm using recursive function, a depth first search, it takes a lot of practice. I finally feel more confident on the algorithm, with so many trials in last 6 months. But today it is the first time the peer asked me to help, I just wrote one line of code, line 17 first. The peer said that she did not know how to continue, so I wrote line 20, 21, 22, 23.
This is the good learning experience for me as well. I like to master the algorithm. One algorithm a time.
Friday, December 1, 2017
Vancouver housing market research
Dec. 1, 2017
I like to do some research about Canadian home price? It is almost eight years since I immigrated to Canada in April, 2010.
Plan to do some research about home price. I talked to one of my Chinese friends a few days ago, she told me that she bought an investment property in Powell River city. It is time to get to know a new city.
I did some research about Vancouver, Burnaby, Surrey, Langley, Abbotsford a few years ago, I drove to Abbotsford once to visit a new community call Abacus Uptown.
Read the article about a bridge, the link is here.
Introduction
I like to do some research about Canadian home price? It is almost eight years since I immigrated to Canada in April, 2010.
Plan to do some research about home price. I talked to one of my Chinese friends a few days ago, she told me that she bought an investment property in Powell River city. It is time to get to know a new city.
Facts to review
On Wed, Dec 17, 2014 at 4:36 PM, a person@quantumproperties.ca> wrote:
Hi Jianmin,
Yes, the studio on the 2nd floor (K2) is still available and is listed at $116,900. We are currently offering a limited-time furniture package incentive worth $4,000 which can also be applied to the purchase price if you didn’t want the furniture, which would reduce the price to $112,900.
Are you interested in purchasing the suite as a primary residence or an investment? I can forward some additional information regarding an investment incentive if you’re interested.
Powell River City
Read the article about a bridge, the link is here.
Swimming is my new sports
Dec. 1, 2017
I start to train myself to swimming every day after the work. Actually I like to do short research how the swimming sports help me to be a better programmer.
Will come back and write down my research.
To stay fit, I should start to get good at another sports besides tennis, an indoor one, fit for the cold weather. Swimming is the No. 2.
Introduction
I start to train myself to swimming every day after the work. Actually I like to do short research how the swimming sports help me to be a better programmer.
Will come back and write down my research.
Argument of the day
To stay fit, I should start to get good at another sports besides tennis, an indoor one, fit for the cold weather. Swimming is the No. 2.
Scan the array
Nov. 30, 2017
Introduction
It is the time to meet a lot of excellent programmers living in pacific coast. I had mock interview at 10:00 PM today. I really enjoyed the coding, specially for linear scan the array, it only took me 14 minutes to go over the explanation and write the code.
I try to use a graph to explain the example and show what kind of problem it is.
C# code is here.
Wednesday, November 29, 2017
Recursive function - H tree
Nov. 29, 2017
It is the first time I practiced to write down the numbers for a H-Tree using given center value and length and depth. I chose to follow the test case with depth 3 and went over the detail to discuss the algorithm.
I tried to do something different this time. I chose to do different on algorithm analysis.
Here is my transcript to do analysis of algorithm. I am working on presentation skills, make the test case easy to follow.
Given depth = 3, draw H tree. First depth is 3, one H tree; next depth is 2, with 4 trees centered on corners of H. So time complexity can be analyzed by the number of trees, here is the formula:
1 + 4 + 4^2 +... + 4 ^(depth -1) = (4^depth)/( 4 - 1).
Each H-tree has 3 lines to draw, O(1) to draw a line, and then time complexity is O(4^depth).
Next work on H-tree three lines, given center (2, 0), length = 4. Draw the graph below, the four corners clockwise from top left are (0, 2), (4, 2), (4, -2), (0, -2).
0 1 2 3 4
2 | |
1 | |
0 | ---------- |
-1 | |
-2 | |
C# code is here.
Introduction
It is the first time I practiced to write down the numbers for a H-Tree using given center value and length and depth. I chose to follow the test case with depth 3 and went over the detail to discuss the algorithm.
I tried to do something different this time. I chose to do different on algorithm analysis.
Algorithm analysis
Here is my transcript to do analysis of algorithm. I am working on presentation skills, make the test case easy to follow.
Given depth = 3, draw H tree. First depth is 3, one H tree; next depth is 2, with 4 trees centered on corners of H. So time complexity can be analyzed by the number of trees, here is the formula:
1 + 4 + 4^2 +... + 4 ^(depth -1) = (4^depth)/( 4 - 1).
Each H-tree has 3 lines to draw, O(1) to draw a line, and then time complexity is O(4^depth).
Next work on H-tree three lines, given center (2, 0), length = 4. Draw the graph below, the four corners clockwise from top left are (0, 2), (4, 2), (4, -2), (0, -2).
0 1 2 3 4
2 | |
1 | |
0 | ---------- |
-1 | |
-2 | |
C# code is here.
Tuesday, November 28, 2017
Busy time in a year
Nov. 28, 2017
It is the best time of year to relax, enjoy swimming and skiing and everything in the city of Vancouver. I started to swim in the community center, paid $48 dollar for 30 days pass. I started from Nov. 27, plan to swim every day, 5 days in the row, and finish 10 swimming workout first.
Also I practice mock interview every week day 10:00 PM. Surprisingly two of my peers are from the city of Seattle. I have good learning experience through mock interview.
I like to do a short research about the city of Seattle, maybe 20 to 30 minutes.
Introduction
It is the best time of year to relax, enjoy swimming and skiing and everything in the city of Vancouver. I started to swim in the community center, paid $48 dollar for 30 days pass. I started from Nov. 27, plan to swim every day, 5 days in the row, and finish 10 swimming workout first.
Also I practice mock interview every week day 10:00 PM. Surprisingly two of my peers are from the city of Seattle. I have good learning experience through mock interview.
the city of Seattle
I like to do a short research about the city of Seattle, maybe 20 to 30 minutes.
Catalan number
Nov. 28, 2017
It only takes 20 minutes to work on Catalan number algorithm. And then surprisingly, the peer asked me to reduce the space from O(n2) to O(n). The peer said that since you finished early, still 10 minutes left.
C# code in practice is here.
Introduction
Code study
C# code in practice is here.
Binary search algorithm
Nov. 28, 2017
It is my most favorite algorithm last six months. My last practice was in less than a week ago, and I made a mistake about the edge case.
On Nov. 27, 2017, I had chance to review the peer's binary search algorithm and I gave out some code review.
So interesting to work on mock interview, I like to write more about mock interview in general on binary search algorithm.
Let me choose a topic and then I write something around the topic.
Focus on middle value
One time in mock interview, I did start value checking in the base case, and then later peer told me that I should focus on the middle
value. The depth first search is about base case, about middle value. Write simple code as possible, avoid discuss start value.
Structure your code very well
There are two ways to write binary search algorithm. Either recursive or iterative, the structure of code should be well structured.
Continue to work, kind of loop
Do some work for base case
Some logic checking to reduce the range of search to half
End of loop
Edge case
Sometime half of range is only one node. In order to include the node into the first half range, the condition should be considered carefully to allow equal sign in comparison. One example is here.
The practice of binary search with the edge case bug is documented in the blog called binary search algorithm is always my favorite.
Converge concern
The binary search is to remove half of nodes every step, the base case is to check if the middle value node is satisfied the condition. In
case the search will not converge, it is better to narrow down the next range as (middle, end] or [start, middle. Exclude middle, at least one node is removed each iteration. There is at most n iteration, where n is the length of the size to search.
References:
Past practice 1: blog is here.
Introduction
On Nov. 27, 2017, I had chance to review the peer's binary search algorithm and I gave out some code review.
So interesting to work on mock interview, I like to write more about mock interview in general on binary search algorithm.
Common mistakes in binary search algorithm
Let me choose a topic and then I write something around the topic.
Focus on middle value
One time in mock interview, I did start value checking in the base case, and then later peer told me that I should focus on the middle
value. The depth first search is about base case, about middle value. Write simple code as possible, avoid discuss start value.
Structure your code very well
There are two ways to write binary search algorithm. Either recursive or iterative, the structure of code should be well structured.
Continue to work, kind of loop
Do some work for base case
Some logic checking to reduce the range of search to half
End of loop
Edge case
Sometime half of range is only one node. In order to include the node into the first half range, the condition should be considered carefully to allow equal sign in comparison. One example is here.
The practice of binary search with the edge case bug is documented in the blog called binary search algorithm is always my favorite.
Converge concern
The binary search is to remove half of nodes every step, the base case is to check if the middle value node is satisfied the condition. In
case the search will not converge, it is better to narrow down the next range as (middle, end] or [start, middle. Exclude middle, at least one node is removed each iteration. There is at most n iteration, where n is the length of the size to search.
References:
Past practice 1: blog is here.
C# string class
C# strong typing study
One more recursive function
Nov. 28, 2017
It is the fifth time I write the recursive function related to C# GetType() in mock interview. I wrote a blog about past practice. One of blogs is here.
This time I came cross two issues in mock interview on Nov. 28, 2017, one is to write String.IsEmptyOrNull, I did not know that the API is static function of String class. In other words, String.IsEmptyOrNull(string s) is the prototype of API.
The second one is to write value.GetType() == Dictionary, which should be value.GetType() == Dictionary<string, object>. It is time to learn more about C# strong typing.
Here is C# code.
Plan to read C# source code of string class, and then write down study notes.
Look into C# strong typing related topic as well.
Introduction
It is the fifth time I write the recursive function related to C# GetType() in mock interview. I wrote a blog about past practice. One of blogs is here.
This time I came cross two issues in mock interview on Nov. 28, 2017, one is to write String.IsEmptyOrNull, I did not know that the API is static function of String class. In other words, String.IsEmptyOrNull(string s) is the prototype of API.
The second one is to write value.GetType() == Dictionary, which should be value.GetType() == Dictionary<string, object>. It is time to learn more about C# strong typing.
Here is C# code.
Actionable Items
Plan to read C# source code of string class, and then write down study notes.
Look into C# strong typing related topic as well.
Monday, November 27, 2017
Internet Information Server 8.0 administration
Nov. 27, 2017
I started my preparation today to ask myself what is IIS-IUsers, why it should assign the privilege to browser the folder?
First, I spent 10 - 20 minutes to read questions about IIS-IUsers and IUSR. Second, I read application pool questions, and then started to play with application pool and then my test site had some issue to show the image, I checked the web browser debugger, and then fixed the issue. Once I started to interact with IIS 8.0 and then I like to know more about IIS system design.
Reading is so much fun and also help me a lot as an administrator.
Here is the list of articles I went through, I spent whole day Nov. 27 to learn and play with IIS 8.0, went through a lot of learning by going through articles one by one.
Nov. 28, 2017
It is time to get organized. Go to google history and find the list of articles I read yesterday, and then review the content, document the rookie to be an administrator of IIS 8.0. It takes time to build up the knowledge. Baby steps are always fun part of learning.
IIS Adminstrator Interview Questions and Answers, the link is here. (rank 5 of 10)
Top 50 IIS Admin interview questions, the link is here.
Nov. 28, 2018
IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 (60 minutes to read, after I spent time to go over the content, I decided to print a paper copy, and then plan to review the content, and mark the content if need. Need to spend more time to look into some keywords)
Nov. 28, 2018
Learn how to enable both ASP.NET 3.5 and ASP.NET 4.5 on IIS 8.0. The link is here.
Role-based or Feature-based installation
Name a few role services:
Management Tools
IIS Management Console,
Web Server
Common HTTP Features (Default Document, directory browsing, HTTP errors), Health and Diagnostics (HTTP Logging)
IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 (60 minutes to read, after I spent time to go over the content, I decided to print a paper copy, and then plan to review the content, and mark the content if need. Need to spend more time to look into some keywords)
google search ".NET v4.5 classic application pool"
Read the article here:
Google search: asp.net IIS server 401 unauthorized
stackoverflow article is here.
Top 8 Application-Based IIS Server Performance Tips
The article link is here.
Google search: application pool identity
The article titled Application Pool identities, the link is here. - 20 minutes to review again.
Will come back later.
Introduction
First, I spent 10 - 20 minutes to read questions about IIS-IUsers and IUSR. Second, I read application pool questions, and then started to play with application pool and then my test site had some issue to show the image, I checked the web browser debugger, and then fixed the issue. Once I started to interact with IIS 8.0 and then I like to know more about IIS system design.
Reading is so much fun and also help me a lot as an administrator.
Here is the list of articles I went through, I spent whole day Nov. 27 to learn and play with IIS 8.0, went through a lot of learning by going through articles one by one.
Nov. 28, 2017
It is time to get organized. Go to google history and find the list of articles I read yesterday, and then review the content, document the rookie to be an administrator of IIS 8.0. It takes time to build up the knowledge. Baby steps are always fun part of learning.
Interview questions
10 minutes to read:IIS Adminstrator Interview Questions and Answers, the link is here. (rank 5 of 10)
Top 50 IIS Admin interview questions, the link is here.
Technical article
IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 (60 minutes to read, after I spent time to go over the content, I decided to print a paper copy, and then plan to review the content, and mark the content if need. Need to spend more time to look into some keywords)
Technical article
Learn how to enable both ASP.NET 3.5 and ASP.NET 4.5 on IIS 8.0. The link is here.
Role-based or Feature-based installation
Name a few role services:
Management Tools
IIS Management Console,
Web Server
Common HTTP Features (Default Document, directory browsing, HTTP errors), Health and Diagnostics (HTTP Logging)
IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 (60 minutes to read, after I spent time to go over the content, I decided to print a paper copy, and then plan to review the content, and mark the content if need. Need to spend more time to look into some keywords)
Technical article
google search ".NET v4.5 classic application pool"
Read the article here:
Technical article
stackoverflow article is here.
Technical article
Top 8 Application-Based IIS Server Performance Tips
The article link is here.
Application Pool Identity Google search
Google search: application pool identity
The article titled Application Pool identities, the link is here. - 20 minutes to review again.
One argument Nov 28th Day 2017
Julia is kind of rush the first day learning, and second day she usually learns more. Yesterday she learns like a monkey. Today she learns like a scholar.
As a monkey style learner, she just quickly goes over as many articles as possible, and see if she can make some sense on any article first. Learn a few things first.
As a monkey style learner, she just quickly goes over as many articles as possible, and see if she can make some sense on any article first. Learn a few things first.
Sunday, November 26, 2017
Computer science graduate entrance exam study
Nov. 26, 2017
It is my passion to help my nephew to prepare computer science graduate entrance exam in Dec. 26, 2017. What I did last 4 hours is to find out what I can help. I started the study around 7:00 pm and ended around 11:25 pm.
I like to look into the book called 王道数据结构全书。
Things I did in 4 hours study:
Call my brother and wechat talk over 6 times, each time I got ideas what to work on.
Find his weakness in the common testing courses
What will be helpful? More mock practice for example, math subject, English, and politics
Contact wechat group to ask help from computer professors
Get some tips for preparation
Look into on baidu.com and see what courses online
Study how to train a young person to deal with the stress
Chat with computer professor from China visiting in Florida as well.
Introduction
It is my passion to help my nephew to prepare computer science graduate entrance exam in Dec. 26, 2017. What I did last 4 hours is to find out what I can help. I started the study around 7:00 pm and ended around 11:25 pm.
I like to look into the book called 王道数据结构全书。
Things I did in 4 hours study:
Call my brother and wechat talk over 6 times, each time I got ideas what to work on.
Find his weakness in the common testing courses
What will be helpful? More mock practice for example, math subject, English, and politics
Contact wechat group to ask help from computer professors
Get some tips for preparation
Look into on baidu.com and see what courses online
Study how to train a young person to deal with the stress
Chat with computer professor from China visiting in Florida as well.
As a matter of a fact, I could not reach my nephew through wechat or cellular phone. Being an aunt, the experience can be so challenging and so funny. It is not easy.
Cordiva contest
Nov. 26, 2017
Plan to spend a few hours to work on the contest today. The contest already ended in Saturday.
The contest link is here.
Plan to spend a few hours to work on the contest today. The contest already ended in Saturday.
The contest link is here.
Canada Immigration study
Nov. 26, 2017
It was Saturday and my own free time. I devoted myself a few hours to study case by case about Canada immigration in hong kong office and understood the normal process.
I just took pictures when I found a good discussion about the case, and shared through wechat to my family small group. I also like to share around 10 pictures here. Later on, I will read again each topic and see if I need to look into more.
Bible teaching is very good on this, if you start to help others, then you also help yourself, enrich your own life.
Introduction
It was Saturday and my own free time. I devoted myself a few hours to study case by case about Canada immigration in hong kong office and understood the normal process.
I just took pictures when I found a good discussion about the case, and shared through wechat to my family small group. I also like to share around 10 pictures here. Later on, I will read again each topic and see if I need to look into more.
Bible teaching is very good on this, if you start to help others, then you also help yourself, enrich your own life.
Saturday afternoon half hour tour
Nov. 26, 2017
It is the third time I tour the immigration and study consultation offices in crystal mall. There are over 5 offices in two floors, I like to get to meet people and then get more prepared to handle my own case to be a sponsor and help principal applicant afterwards.
This time I also ask about studying in Canada. To sponsor a twenty-three years old young Chinese with an undergraduate degree, I like to prepare myself to get to know more about education of Canada, therefore I can give out advice to a young relative.
Here are the offices I visit:
1. Ocean ventures education & Immigration Consultants Inc. Here is the website.
2. Canada starlight education group, www.viecanada.ca
3. Maple path consulting ltd
Plan to study the website www.yueyangvisa.com, it is a very good place to understand how Canada helps new immigrant. I already found a few good articles.
I had special thanks to consultants in the office of Maple path consulting ltd, I was really appreciated that they gave me good free consultation, and we had good conversation about the immigration application experience.
Introduction
This time I also ask about studying in Canada. To sponsor a twenty-three years old young Chinese with an undergraduate degree, I like to prepare myself to get to know more about education of Canada, therefore I can give out advice to a young relative.
Here are the offices I visit:
1. Ocean ventures education & Immigration Consultants Inc. Here is the website.
2. Canada starlight education group, www.viecanada.ca
3. Maple path consulting ltd
Plan to study the website www.yueyangvisa.com, it is a very good place to understand how Canada helps new immigrant. I already found a few good articles.
I had special thanks to consultants in the office of Maple path consulting ltd, I was really appreciated that they gave me good free consultation, and we had good conversation about the immigration application experience.
Saturday, November 25, 2017
Alexis Ohanian | Full Talk and Q&A | Oxford Union
Nov. 25, 2017
I was planning to go out to play tennis, and then I stopped for the video about Alexis Ohanian. I finished the 50 minutes video. Now it is 3:35 PM Nov. 25, 2017.
I like the talk and like to write down some notes about the talk.
I was planning to go out to play tennis, and then I stopped for the video about Alexis Ohanian. I finished the 50 minutes video. Now it is 3:35 PM Nov. 25, 2017.
I like the talk and like to write down some notes about the talk.
The Undefeated In-Depth: Serena with common
Nov. 25, 2017
I have two hours left before it is getting dark in Vancouver. I need to go out to play tennis. Now I need to prepare a short lunch for myself, and I am in the middle of this interview. 47 minutes video from ESPN interview, called The Undefeated In-Depth: Serena with Common - Serena Williams 2016 ESPN interview.
The video link is here.
I have two hours left before it is getting dark in Vancouver. I need to go out to play tennis. Now I need to prepare a short lunch for myself, and I am in the middle of this interview. 47 minutes video from ESPN interview, called The Undefeated In-Depth: Serena with Common - Serena Williams 2016 ESPN interview.
The video link is here.
Subscribe to:
Posts (Atom)









