Wednesday, February 28, 2018

JavaScript: From Fundamentals to Functional JS, v2

Feb. 28, 2018

Introduction


It is the second month I subscribed the frontendmasters.com. The first month I spent less than 5 hours on the website. I have to discipline myself and work on some courses.

JavaScript course


I plan to spend two hours on this course first in short future.

Leetcode 289: Game of life

Feb. 28, 2018

Plan to write C# code to practice the algorithm called Leetcode 289: Game of life.

Deletion distance

Feb. 28, 2018

Introduction


I had a mock interview on Feb. 27, 2018 10:00 PM. I wrote deletion distance algorithm again.


Code review


Here is the C# code.


Computer maintenance

Feb. 28, 2018

Plan to work on the algorithm called Computer maintenance.

Bus station

Feb. 28, 2018

Plan to work on the algorithm called Bus station.

Single number IV

Feb. 28, 2018

Plan to work on the algorithm called Single number IV.

Tuesday, February 27, 2018

Find smallest substring containing unique keys


Feb. 27, 2018


Introduction


I had two mock interviews as an interviewer and the algorithm is find smallest substring containing all keys. I had chance to observe how top university graduate learned the algorithm from the scratch. I know that it is hard level algorithm, even though one of peers is top graduate and very well educated, but understanding the idea and putting them into the code are two different talent. I just learned that the peer wrote a portion of the algorithm to use a hashset to check sliding window containing all keys or not.

The code was so buggy and even I could not handle the code very well. I missed the bug even after I reviewed the code. It took us more than 10 minutes to work on the code together.

Through the process, I definitely could tell that the peer was working very hard. The peer communicated very well.But coding takes some practice. It cannot be shortened without failure, mistakes, and all kinds of issues in-between.


Code review


Since I reviewed the code, I should claim part of the ownership of the code. I should copy the code and remind myself later on, be more careful when I review the code.

The mistake is
unorder_set<char> map
...
map.insert(arr[left])
map.insert(arr[right])

The char should be str[left], str[right] instead. I made the same mistake before to mix two variable names, from that on, I always go ahead in the beginning to change the variable names in the meaningful way.

Exponential algorithm research

Feb. 27, 2018


Introduction


Float number and operator algorithm is not too difficult but most of interviewees including myself cannot reduce the exponential algorithm to linear algorithm the first time. I spent 30 minutes to be an interviewer on Feb. 27, 2018 10:00 PM and then also had chance to review the algorithm again.

I like to do a small research how to reduce exponential algorithm to linear algorithm.


An algorithm book


I found a book to read and actually I spent over 30 minutes to read the book. It is called Exact Exponential Algorithms

What to learn from a data scientist?

Feb. 27, 2018

Introduction


I had chance to work with a peer two days ago who is a data scientist working for a biggest bank. I like to do a small research, what to learn from a data scientist quickly in 30 minutes to help him solve Spiral Matrix algorithm?


Monday, February 26, 2018

Lintcode 818: Subset with target

Feb. 26, 2018

Introduction


I like to try various ideas and one of ideas is to read the analysis on jiuzhang.com, and see if the analysis in Chinese can help me understand better on the algorithm.


Analysis in Chinese


One thing I like to do is to write down the Chinese analysis first, and then translate them into English.


Lintcode 819: Word Sorting

Feb. 26, 2018

Plan to study the algorithm called Word sorting.

Here is the solution blog.

Lintcode 820: Rectangle

Feb. 26, 2018

Introduction


I plan to study the algorithm called Lintcode 820: Rectangle.

I read the analysis based on Jiuzhang.com. It is so interesting.

Hint given by Jiuzhang.com

Enumerate two points crossed in rectangle, and use hash to judge if the left two points are existing.



Lintcode 821: Time intersection

Feb. 26, 2018


Introduction


It is very good habit to write a blog for each algorithm. I like to learn some new algorithms and this algorithm is called Time intersection. Here is the link.

Algorithm


One of solutions is here. I like to study the algorithm based on the gist I created for the algorithm.


Sunday, February 25, 2018

Find minimum substring containing all unique keys

Feb. 25, 2018

Introduction


It took me 25 minutes to analyze the algorithm and also write C# code. I used exactly 30 minutes to complete the task.

Code review


Here is the C# code passing all test cases.



Comparison to the practice 5 month ago


The code I wrote is much more simple compared to the one I wrote more than 5 month ago, I can look up the code through the question I asked on stackexchange.com.

The while loop to handle left pointer is much simple using one variable to count unique keys in sliding window. The loop invariant is clear and short compared to the one asked in the code review. The loop invariant in the while loop in the code review is giant expression and should be shortened.

Spiral matrix algorithm

Feb. 25, 2018

Introduction


It is so exciting to learn some ruby and also learn how the peer wrote the algorithm quickly with only two edge cases mistakes, one is one row and another one is one column case.

Code review


Here is the ruby code I code reviewed.

Most important is to observe how top programmer can find out where the code will fail in less than one or two minutes, and then start to think about the fix. In less than five minutes, we worked together and put the fix together. Amazing speed to fix everything. Only thing I did is to ask the peer to think about one row and one column edge case before he likes to run the web compiler.

Line 26 and Line 32, Line 26 one more checking is added "x_min < x_max"; line 32 "y_min < y_max" is added.


Learning time Sunday day night



The Sunday 8:00 PM mock interview is such a great surprise, I had chance to learn how a top programmer and lead in the medium size team performs so well and work with the interviewer so efficiently on my favorite algorithm Spiral matrix.

Becuase of my super performance as a mock interviewer, I had chance to get to know the peer and then I could undertand how a person works very well in mock interview, he did very well in industry as well.

Array of array products

Feb. 25, 2018

Introduction


It is 4:00 PM mock interview. I had to work on the dynamic programming algorithm. In the analysis, I analyze the right to left dynamic programming method, and I need to work on two multiplications each iteration. But I wrote down a line on line 58 which is wrong:

product[i] = product[i] * arr[i + 1] 


Code practice


The peer gave me the hint, and then I wrote down line 63 and line 64:
line 63:  rightProduct   = 1,
line 64:  rightProduct *= arr[i + 1]

I like to figure out what I should do to come out the correct analysis in the first time. If I am a teacher and I teach algorithm every day, I may come out a few ideas to help myself to follow certain steps to write correctly on whiteboard. 

Right now I only emphasis two multiplications in right to left iteration using dynamic programming methods. But I still could not connect dots in between. Do not worry, next time I will make it perfect. 

Here is my code practice in C#.

Find first missing number

Feb. 25, 2018

Introduction


It is part of my training idea, practice until you cannot get it wrong. I had a mock interview this morning at 10:00 AM. I did write down the idea to do in place swap to find the first missing number. And then I wrote code with a few bugs, I failed a few test cases, and then I fixed the bugs on line 15 and also line 16.

Practice until you cannot get it wrong


One thing I like to train myself through mock interview is to pay attention to small detail. The peer asked me to work on the optimal solution using in place, and then I came out the idea but I did say something to change the value to negative one if the value is bigger than the array size. And the code I wrote was not correct, I ran into index-out-of-range error and failed a few test cases. I fixed the bugs of course very quickly.

Line 18 swap function should be called only after the index is in the array's range.

Here is C# code.

The mistakes I made in my first writing just reminds me that I have to train myself hard than before.

JavaScript and bootcamp

Feb. 25, 2108

Introduction


It is the best thing to do in the Saturday morning. I had a mock interview at 10:00 AM. I had chance to meet one  young programmer, and also know the boot camp of hack reactor, and also learn some JavaScript and have chance to practice binary search algorithm with the peer.


Code review


The peer shared me with advice to take a look a JavaScript book: Eloquent JavaScript. I reviewed the JavaScript code, here is the link.

One thing I did is to share the tip how to round up the value in JavaScript by yourself, line 17: parseInt(candidate * 1000 + 0.5) / 1000.0. The JavaScript type conversion can be completed using parseInt function.




Friday, February 23, 2018

Neurodiversity hackathon

Feb. 23, 2018

Introduction


I like to write something for my favorite Microsoft hackathon called Neurodiversity Hackathon.

It is the learning experience, I did not know how good people are to work on hackathon. It is like China open in Beijing, I had chance to watch the top professional players how to train themselves in practice court in 2017. In practice court, I saw players practice together and how they cheer each other, and I was so close to players, sometimes only a few meters away.

I had the opportunities to learn from two team members how they wrote code using Microsoft emotional API and then successfully did the work.

What is autism?

What is Microsoft emotional API?


Here is our code ! Get excited!


Here is the link of code.

Here is the place for the project on linkedIn.com.

What is my plan after the hackerthon?



Longest arithmetic progression algorithm

Feb. 23, 2018

Introduction


It is my ideal learning to share my practice on code review website,  I know that it takes a lot of practice for me to master a dynamic programming algorithm.

I spent hours to study and write C# code, and when I like to share my practice with other people on code review website, I have to go over the reading material again and also think over again carefully. I find that it is very good experience. It is good to help others later on if I choose the algorithm as a mock interviewer, and also it is very helpful for me to examine my past week's hard work, what I should improve as a competitive programmer.

Are you currently working?


Two days ago I attended HackerX event in the downtown office Visier. I met two employers and both of them asked me the same question. Are you currently working? I know that it is very interesting question.

I am working full time.

I also try to improve myself by practicing a lot of mock interviews. I also like to invest some time to help others, learn to be a coach to help others to achieve their goals.

I start to practice with some peer met on mock interview platform, so I had chance to practice some algorithm together with the peer. I enjoy learning and find myself pick up more soft skills. Being a software programmer can be so much fun.


Algorithm practice


I spent one hour to review the algorithm and managed to post the question on the stackexchange.com website. Here is the link.

Wednesday, February 21, 2018

Leetcode 140: Word break II (VI)

Feb. 21, 2018

Introduction


I like to practice the idea shared by the students with a coding blog and also with a record solving more than 500 Leetcode algorithm. I like to learn from the player. Here is the link.

Here is the idea I learned from hard level algorithm regular expression matching on mock interview. After I practice over 10 times with high ranking peers, I quickly learned so many things and am confortable to write a dynamic programming solution.

I like to choose 10 people to learn from and then write code based on their sharing.


Leetcode 140: Word break II (VI)

Feb. 21, 2018

Introduction

One idea to learn a hard level algorithm is to give some support for the other people. I found the post with sharing tips how to avoid TLE error, so it is good to try the idea as well. Here is the link. I voted before I try the idea.


Leetcode 140: Word break II (V)

Feb. 21, 2018

Introduction


Plan to write my fifth practice based on the idea using DFS + DP + Trie. Here is the discussion link. The student completed more than 444/761 questions. I like to learn from the player.


Algorithm practice

Feb. 26, 2018 8:45 PM
Here is my C# code. The class TrieNode's design is interesting. It took me sometime to figure out and know that it will work.



Leetcode 140: Word break II (IV)

Feb. 21, 2018

Plan to write C# code based on this Java code DFS with pruning idea. Here is the link.

Leetcode 140: Word break II (III)

Feb. 21, 2018

Introduction


It is a good idea to study some code and then write the idea using C# programming language. I do know that one thing I can improve to learn a hard level algorithm is to read as many as possible ideas with solutions. And then I should practice some coding.

Specially the first hour of the day is best time for me to train myself to write good code.

Here is Java code using DP and Trie. I like to write one using C#.

Leetcode 140: Word break (II)

Feb. 21, 2018


Introduction


It is my idea to learn the hard level algorithm. Write at least 10 implementation and write as many ideas as possible.

Here is the idea for my second practice.



Tuesday, February 20, 2018

Hackerank: Road in hacker land

Feb. 20, 2018

Introduction

It is my favorite algorithm called union find algorithm. It can be Kruskal algorithm. I did have a lot of practice recently. It is so good to come back to work on the algorithm again.

Algorithm study 

Plan to review the algorithm by studying the blog.

题意
给一个联通的无向图,求所有点对之间的距离和。其中每条边的距离都是 2 的幂且互不相同。
题解

  • 每条边距离为 2 的幂且不相同,意味着选择长的边很可能是不好的。
  • 这道题跑最短路显然不大可能,因为需要求所有点对的距离和。最优解是最小生成树,接下来来证明。
  • 假设最优解不是最小生成树,那么去掉其中长度最长的边(长度为 k)后再增加若干条长度小于 k 的边仍能使其联通。先去掉最长的边,那么有一些点对会无法联通,这些点对的距离至少为 2^k,现在增加一些边使其联通,那么这些点对的距离至多是 2^0+2^1+2^2++2^k−1<2^k,从而得到一个更优解,所以假设不成立。
  • 既然是最小生成树,那么需要求一下这棵树上每条边的贡献,这个问题就比较简单了,跑一边 dfs 即可。

Coding


Please use the code for Union find algorithm Island count II for the template, and apply the same technique on this algorithm. Here is the link. 

Quick union algorithm

I like to review the practice on quick union algorithm. Here is the link: 

Quick find algorithm

I reviewed the quick find algorithm more than one month ago. Here is the link: 


A mock interview discussion

I remembered that the peer gave me the question and test my disjoint set data structure. I chose to use depth first search and then had some idea to use hashset only data structure. Here is the discussion.


Algorithm blog beyond my level

Feb. 20, 2018


Introduction


I chose to stop playing Hackerrank week of code 36 since I know that I have to work on more on mock interviews instead. But I did catch up things on week of code 36, I spent around two hours in the contest to try to solve the hard level algorithm. One thing I followed up after the contest is to look up submission of the hard algorithm, I went over all submission with full score on the hard level algorithm, checked profiles one by one. A few of them are working for Google, and a lot of them are players I know before, but this time I did find a nice player with great sharing his coding blog.

It is kind of different feeling. I do not want to stop on Leetcode algorithm only. I know that those algorithms are serving best for the interest of interviews, but I like those algorithm hard and make me excited and could not stop thinking about all the time.

In other hand, I do know that my learning of algorithm should also focus on the foundations.

Algorithm blog


It is hard level algorithm blog. All those algorithms are beyond the normal interview of Google/ Facebook questions. But it is good for me to train myself once a while.

Here is the list of algorithms on the blog.

My Tennis life: Lucie Safarova Episode 1 "Don't Let Coach Rob Do The Dishes"

Feb. 20, 2018

Introduction

I used to take videos for my tennis training. And then I like to do something these days for my training of mock interview.

Here is my favorite videos and I like to learn from those professional tennis players. Top 10 ranking players really give the fan good insights how to work with coaches.


Surviving the WTA tour ... after 30

Feb. 20, 2018

Introduction


I like the creative ideas from the great coach. I was not a great coach and then my nephew did not like to take my advice last few months. I wrote a blog to document my frustration.

It is time for me to learn from my favorite tennis player and coach, here is the video called surviving the WTA tour... after 30.


I want to be a good coach

Feb. 20, 2018

Introduction


Life is so tough and then I learn the hard lesson. I have so many friends who works as a computer professor in university of China, I spent over four hours to do research and got some advice from them last November, but I could not help my relative, because he refused to take my calls and answer my wechat, I talked to my brother over and over again. This February he did not pass the minimum required score, the graduate admission test was in this January, 2018.

I like to do some research and work on a few things. Why I can tell that he will fail from his behavior? Does good student have a good pattern of learning? Showing curiosity or having a good attitude?

Why the math is tough subject for my relative?

How to guide him to prepare for an graduate study in Canada in short future?




Train insane or remain the same

Feb. 20, 2018

Introduction


I always like to answer people why I continuously practice mock interview. I believe that I treat it like a research project. I like to find out what I can learn quickly through those practice.

I love to meet people and then have discussion related to the algorithm and data structure. I just treat the mock interview as one of my research projects, things I can work hard and then see if I can make a difference on myself or the peer. Learning and teaching are most interesting things I like to do.

I love to teach algorithm and data structure, I go through those long hours to work with peers on algorithm problem solving. From those experience, I educate myself to be super patient when I meet an algorithm and I need to break through in less than 20 minutes.


My two mock interviews


One thing I did last weekend is to go through the mock interviews from a startup company, and so surprisingly I passed two round of mock interviews, first one is average 2.7, second one is average 2.5.

Life is such a great teacher. One of my friends told me that he did first one 3.2 but second one did not pass passing bar 2.5, which is below 2.0.

So I suddenly find out that I should think about it. Do not take it for granted. At least I should write down and then later on I can tell something from this experience.


Leetcode 301 Algorithm practice


I like to figure out how to improve my practice. Just before the mock interview to work on remove invalid parentheses, I worked on leetcode 301 hard level algorithm continuously from February 3 to February 7 2018, and my goal was to practice over 10 times and also tried various ideas. Here is the list of practice by searching the blog using Leetcode 301.

One thing I like to look into is that I could not recall the tip to remove invalid parentheses. The most simple way to remove invalid parentheses is to remove unmatched close bracket first, and then reverse the string, and then handle the same subproblem.

What I can tell is that the practice does not help right away for the mock interview. I got the average score 2.5, but score of coding is 2.3. I did know that I just practiced the algorithm and got my hands on those ideas one by one, but I could not quickly enough to apply related work to the problem solving right away. The interviewer gave me 5 minutes talk after mock interview, he told me that the first algorithm took me around 30 minutes which should less than 20 - 25 minutes.

What if I did not review the algorithm, and went over all the practices I did over 6 hours.


Sunday, February 18, 2018

Find if there is a rectangle in binary matrix with corners as 1

Feb. 18, 2018

Plan to work on the algorithm. Here is the link.


Leetcode 140: Word break II (I)

Feb. 18, 2018

Plan to work on the algorithm called Leetcode: word break II. Here is the link.

I like to start to practice over ten times, using various idea.

The first practice is based on the discussion link here.

Count the number of the ways an integer can be represented as a sum of consecutive positive integers

Feb. 18, 2018

Plan to work on the algorithm, the link is here.

Longest arithmetic progression

Feb. 18, 2018


Introduction


It is the most difficult dynamic programming algorithm I have worked on before. I just could not believe that we do not have a lot of blogs and articles to talk about it. I was thinking about posting one on stackexchange.com in short future.

One thing I like to look into is how the startup company in Sillicon Valley chooses algorithm for the phone screen, what kind of talent is at the top of the free market now these days?

I do know how tough it is to survive a 20 minutes mock interview using this algorithm.

Plan to work on the solution. Here is the link.

Algorithm practice


Here is the C# code practice I had recently. I did find a blog with test cases. After I went through the test case, I understood the algorithm and how it works.


Actionable Items


I like to read the papers related to the algorithm, and see if I can understand the paper one day. Here is the link.

Here is the post on stackoverflow. And the answer I voted is here.



Leetcode 109: Convert sorted list to binary search tree

Feb. 18, 2018

Introduction


It is so excited to share my practice experience today. I had discussion with the peer on the algorithm Leetcode 109. The peer asked me to give him a tree problem, recursive solution problem. His request is based on the fact that recursive function is hard to figure out but it is easy to write in a few minutes.


Mock interview discussion


The peer wrote his analysis and spent around 10 minutes. I asked what is time complexity for his algorithm. He told me that it will be O(N2). So I chose one of leetcode discussion and then asked him having a discussion based on the solution provided over there.

Here is the discussion we had on the post on the leetcode discussion. O(n) time solution with O(1) space.

I will write down 5 minutes talk I gave to the peer. I just could not believe that I did make some comment and also the peer seems to like my comment.


There are two things to talk about related to the algorithm:

1. First the binary search tree inorder traversal will output the tree nodes in the ascending order;
2. If there is only one node in the sorted list, how to convert the list the binary search tree? What is the time complexity?

Definitely the node will be the root of the tree, and then left substree is empty and right subtree is empty.  Assume that the hint is given to traversal the tree once from the list.

The recursive function is designed this way that it is against the intuitive. The tip is that do not overthink, be a lazy and relaxed programmer. Work on the minimum coding and thinking. The linked list will travel once to next in the recursive function. If the linked list is one node, the travel will go to null from the start node.

The reason I made this talk is to remind myself that next time I come cross the problem, I will not be nervous, and I can figure out in less than five minutes.

Hashset and trie data structure design

Feb. 28, 2018

Introduction


It is such a great blessing to have a peer to share his experience. I learn one more algorithm from the peer today. The peer told me that I should not choose Trie data structure right away, I have to ask questions to collect use cases, and then define the data structure for each case.

20 minutes discussion 


Here is the algorithm we discussed in 20 minutes. I tried to give out a solution using Trie, and then I define Trie class using recursive tree.

It is most important to write a basic solution using recursive function first. Here is C++ code I like to review later.


Research about algorithm practice

Feb. 28, 2018

Introduction


It is the good idea to choose one research topic in the Sunday and then I like to find some good arguments to think about in short future.


Short research


Here is the article I read. I like to go over word by word, and organize them in the best format.



准确来说,刷题风是2013年之后开始普及,那么为什么呢?2013年后和之前的硅谷相比发生了几件事情:

Please understand a few concept first:

30W package
flg - Facebook, Linkedin, Google
ios/android bootcamp
rsu
startup
刷题最高
洗脑活动

Facts:

1. Facebook上市并开始盈利,形成了以前硅谷Google一家高薪和后来两家互抢的情况(当时还有Linkedin)。注意到 2012 之前其实 Google 的薪资只是略高于一般公司,没有达到某种量级的不同,后来就成了 30w 包裹成标配的感觉.

2. 股票价格上升. 美国互联网经济进入黄金时代,这带来的就是创业潮(泡沫),各种 startup 为了抢人,反正 paper money 不是钱,各种以 rsu 形式发送的“大”包裹开始出现,flg的 30w 算啥,“价值百万”的 rsu 要不要?上市后还很可能 double!马上财务自由!

生活在硅谷是一种什么体验?

就是刷题的体验!

国内的以为硅谷是什么创新,是什么灵感,是什么天才。硅谷的中国人就是继续发挥着国人考试的天赋,把工作面试硬是做成了高考准备一样的刷题模式。

你以为到了硅谷就是发挥你的聪明才智像国内鸡汤文写的什么“工匠精神”一样认真潜心做一个东西N年?你当码工是傻逼么?

哪里钱多就往哪里走,或者哪里可能钱更多就往哪里走. 这才是硅谷精神!

当你年收入少的时候,别人当你是笑话;

中国的高考是寒门子弟翻身唯一机会,而在硅谷,刷题则是在校留学生、小公司不得意者、创业失败者翻身的唯一机会!因此在硅谷形成了一个在全世界都看不到的现象:刷题成风,世人皆刷题。

硅谷的所有公司,就是用着这些题目对面试者进行最基本的筛选。

你是大学教授?哦,来做个题看看先,请实现上面某个问题的算法并用java或c++或python来实现. 嗯?你不会写代码?we decided not moving forward.

你是某公司 CTO 或技术总监?来,我们来做个 bfs 的题目。讲讲思路行不行?讲思路啊,讲完请在面前的白板上把你的思路写成可以运行的程序代码。15分钟过去了,还没写出来?we decided not moving forward.

你发表了研究论文无数?真牛逼,来,我们来做个题目比如在一个数组中找出4个数的和等于某个给定数字的所有组合,要快哦!。20分钟过去了,怎么,你居然没写test case?sorry, we decided not moving forward.

悲伤和喜悦的故事每天都在硅谷发生。和中国的高考一样平等,所有人,无论你是教授、公司老板、技术大拿、经验丰富的工程师、名校学生、烂校差生、学文科转行的,也不管你面试的职位是初级工程师、高级工程师、技术带头人。在这里都面临着同样的门槛:白板做题实现算法


Catalan number

Feb. 18, 2018

Introduction


It is my favorite quote saying that practice until you cannot get it wrong. On Feb. 17, 2018 I practiced the algorithm Catalan number but I got it wrong.

I had some issue with understanding n-grid.

Code review


I will look into the issue later. Here is the C# code.

Word count practice

Feb. 18, 2018


Introduction


It is hard for me to master the algorithm called word count practice.  I have to work on the string manipulations, such as lower case, remove extra chars, and split string using regular expression, and then group by the value and sort by input string order.


One more practice


Here is one more practice I did on Feb. 17, 2018 10:00 PM mock interview, I wrote 20 minutes.

Is the smartest one anonymous?

Feb. 18, 2018

Introduction


One a while I will choose a topic to do research, today I have a mock interview and then I learn something from the peer. Since the peer is working on important phone interview in next week, he chooses to stay anonymous. I think that it may be a good sign that he is super talent and will be next great top programmer.

Anonymous is good choice


Let me do some research on this topic. 10 - 15 minutes and see if I can make some progress on this research.


Feedback 


Let me share the feedback I got. So I know that the most important lesson for me to learn is to stay humble, and also work hard.


Remove invalid parentheses

Feb. 18, 2018


Introduction


It is best opportunity for me to work with another peer on the same algorithm. I write the algorithm through mock interview last Saturday and then continued to practice a few hours using C#. I also have chance to review C++ code from the peer. Learning algorithm is such a small group activity, I have to learn from others and start to get to know more about C++ through code review.

Today I got some C++ code to review on the algorithm called remove invalid parentheses.

Code review


Here is the C++ code.


Find smallest substring containing unique keys

Feb. 18, 2018

Introduction


It is my most favorite algorithm in 2018 called find smallest substring containing unique keys. That is the algorithm I have practice over 10 times from March 2017 to February 2018. And also it is the most popular interview question and I had one in 2015 January. I had a very good experience 45 minutes since I could not pass the phone screen, but I learned to be open and welcome the challenges as a programmer, show the world that I do care about learning the algorithm, and keep working hard as a software programmer.

This algorithm is the reason I start to write a coding blog starting from May 2015. I knew that I was not so good at learning, but I just started to document my learning and my emotions like feeling of struggling and then enjoy the journey to be a good thinker in algorithm and data structure.


My experience of interviewing


It is the Sunday morning 10:00 am mock interview. The peer had to work on the algorithm, and I worked with the peer 70 minutes until she finished the code, and also passed all test cases.

The first 30 minutes I went over my own blog to review the past practice, and once a while I stopped and gave some advice to the peer.

I do enjoy the interview. I do not have coworker as a programmer in my work place, I am a solo programmer. I really know that it is my own task to find the chance to work with people.

I learn from my experience on this algorithm, so I also like to share the tips to the peer through the mock interview.

Here is the C++ code I reviewed, and the code passes all test cases.

Here is the comment I wrote to share the advice after the mock interview.

My feedback after the mock interview


The peer worked very hard and also very open to advice, took the hint. The peer wrote the algorithm around 70 minutes including discussion, fixing all the bugs etc. 

I like to share that I could not finish the smallest substring algorithm in my first five practice on the mock interview platform, in 30 minutes. I had different issues, but last 3 or 4 times I kept got very good peer to help me, one is really good. Please take a look here, the peer helped me.  And the other one is also good, the peer helped me to pass all test cases in 30 minutes, here is my practice blog. 

Just practice the same algorithm again and again, work on one thing a time. 

Saturday, February 17, 2018

Remove invalid parentheses

Feb. 17, 2018

Introduction


It is my most favorite algorithm to work on recently. I started to work on Leetcode 301 - remove invalid parentheses, a hard level algorithm

Time line


Step 1:

I had 9:30 AM mock interview, and the algorithm I had to work on is to find minimum valid parentheses. Based on the interviewer's advise, I had to work on step 1, remove invalid parentheses.

It should take me at most 20 to 25 minutes to finish the algorithm and also coding, but I actually spent over 35 minutes but the code has bugs.

Here is the code in mock interview

Step 2:

Started from 1 PM, I worked on the code I wrote in mock interview, completed the code, and the code has bug. Here is the code.

Step 3:

2:47 pm, I rewrote the code using different design, and complete the test cases. The code is here for remove invalid parentheses.

Step 4:

Not it is 2:55 PM, I organized all the past practice Leetcode 301, added tag for each post using tag: Leetcode 301: remove invalid parentheses. All the past practice can be looked up by the tag now.


Actionable Items


March 5, 2018 8:10 PM
It has been more than three weeks, I think about carefully what really the problem is for this algorithm problem solving.

I need to simplify the problem I need to solve.

Wednesday, February 14, 2018

Float numbers and operators

Feb. 14, 2018

Introduction


It is 10:00 PM mock interview. I gave the second algorithm for the peer to work on. The peer is very smart and took hint quickly, after he got the hint to keep maximum and minimum value, he wrote the optimal solution in less than five minutes.

I just could not believe my eyes. And after mock interview the peer told me that he is preparing onsite interview next week.

Code review


Here is transcript of mock interview.

Leetcode 124: Longest consecutive sequence

Feb. 14, 2018

Introduction


It is the hard level algorithm and also it can be solved using dynamic programming method. It is called longest consecutive sequence.

Study notes


I wrote down the study notes. Here is the link.


Leetcode 300: Longest common subsequence

Feb. 14, 2018

Introduction


It is the medium level algorithm and can be solved using dynamic programming. This dynamic programming algorithm is getting easy since I have worked on the dynamic programming algorithm deletion distance over ten times last 11 months, and one of solution is to use longest common subsequence.

Algorithm study


I spent around 20 minutes to go over one blog and wrote down my study note. Here is the link.

Back pack algorithm (II)

Feb. 14, 2018

Introduction


It is the traditional dynamic programming. It may take me a few minutes to come out the solution if I study the algorithm very often.

Here is my study notes.

back pack algorithm

Feb. 14, 2018

Introduction


It is the most popular dynamic program algorithm. I also wrote down the notes how to analyze the problem in a simple recurrence formula. Here is my study note.


Dynamic programming article

Feb. 14, 2018

Introduction


Chinese is my mother language. I like to see if I can learn dynamic programming quickly by reading some article in Chinese.

I started to review dynamic programming from the most popular blog in Chinese written in 2014. Here is the blog.

Study notes


One thing I like to do is to go over the blog word by word, and organize it better for me to read next time.

Here is one of articles I read and I saved the content to the gist.


Tuesday, February 13, 2018

Leetcode 115: Distinct Subsequences

Feb. 13, 2018

Introduction

It is time for me to read more Leetcode algorithms in next week. I like to go over 150 algorithm and see if I can read the algorithm blog and come out the idea by myself, or I can try to understand the hint given by the blog.

I like to work on hard level algorithm Leetcode 115: Distince subsequences, based on the analysis from the blogger. Here is the blog link.




Leetcode 154 algorithm review

Feb. 13, 2018

Plan to read Leetcode algorithm blogs written by top ranking blogger one by one. Here is the link.


4 sum algorithm

Feb. 13, 2018

Introduction


It is 8:00 PM mock interview. I spent 18 minutes to write 4 sum algorithm based on the advice from the peer, do not use extra space, using two pointer technique,  I wrote the algorithm. The total interview took us 38 minutes.

Code review


Here is C# code.

Design a chess game

Feb. 13, 2018

Plan to read the design question on stackoverflow.com. Here is the link.


Design a parking lot

Feb. 13, 2018

Plan to read the post on stackoverflow called design a parking lot. Here is the link.

Leetcode super talent

Feb. 13, 2018

Introduction


It is my interest to find good mock interview algorithm. I like to look up those Leetcode algorithm and determine which ones to study.

Today I came cross this website. I could not believe that the graduate student of Tsinghua university already completed over 600 algorithm practice on Leetcode, and also wrote down the summary for most of algorithms.


Feb. 27, 2018

I could not believe that I was so busy last 2 weeks. But I came cross the blog and then decided to read the leetcode algorithm one by one. My ideal of

training is to cover as many Leetcode algorithm as possbile. I like to train myself to think more about analysis, review the code and also ask myself a

few questions for each algorithm.

The beautiful journey began here.

The Leetcode blog I chose to read for my first one or two hours:

Leetcode summary 201 - 300



#285
#286
#287
#288
#289



Actionable Item


I like to go over as many algorithm as possible. Go over the algorithm and think about for the idea. Try to find some interesting problems to work on. Get used to training, analysis algorithms daily and also keep myself to solve new problems 5 to 6 of them every day.


Do not stay on the same algorithms too long. I already work on the same set of algorithm around 30 of them on mock interview, I know that it takes time to learn and good to learn from so many people.

I also need to try new algorithms every day so that I can get used to think and push myself hard every day.

Here is the blog to go over 500 Leetcode algorithm by the Ph.D., ex-Microsoft and Snap software engineer.



Leetcode 128: Longest Consecutive Sequence (II)

Feb. 13, 2018

Introduction


It is the hard level algorithm. I chose to study the algorithm since the blogger wrote a blog abut Leetcode Spiral Matrix, and today I chose to review my blog in 2015, and then I had chance to review the summary of Leetcode graph problems.

Algorithm 


The blogger talked abut using graph and depth first search technique to find optimal solution based on time complexity O(n). The array does not need to be sorted, and the graph including all elements in the array can be expressed in a hashset.

Here is the gist I created to study the blog. And here is the C# code I wrote based on Java code.

Analysis of the algorithm


What I like to do is to go over the analysis of algorithm written in Chinese in the above blog. And then I like to highlight a few things, and make some arguments.

Constraints:
The array is not sorted. It is integer array.
Need to find longest consecutive subarray.

Ask:
longest consecutive sequence - greedy algorithm

What is consecutive sequence?
You can start any element in the array, and then search its left side and then right side and find all consecutive sequence include the number.

O(nlogn) time complexity algorithm

这道题是要求出最长的整数连续串。我们先说说简单直接的思路,就是先排序,然后做一次扫描,记录当前连续串长度,如果连续串中断,则比较是否为当前最长连续串,并且把当前串长度置0。这样时间复杂度是很明确,就是排序的复杂度加上一次线性扫描。如果不用特殊的线性排序算法,复杂度就是O(nlogn)。


Think in Graph


其实这个题看起来是数字处理,排序的问题,但是如果要达到好的时间复杂度,还得从图的角度来考虑。思路是把这些数字看成图的顶点,而边就是他相邻的数字,然后进行深度优先搜索。通俗一点说就是先把数字放到一个集合中,拿到一个数字,就往其两边搜索,得到包含这个数字的最长串,并且把用过的数字从集合中移除(因为连续的关系,一个数字不会出现在两个串中)。最后比较当前串是不是比当前最大串要长,是则更新。如此继续直到集合为空。如果我们用HashSet来存储数字,则可以认为访问时间是常量的,那么算法需要一次扫描来建立集合,第二次扫描来找出最长串,所以复杂度是O(2 * n) = O( n ),空间复杂度是集合的大小,即O( n )。

Leetcode 282: Expression add operators

Feb. 13, 2018

Plan to work on hard level algorithm Leetcode 282: Expression add operators.

Monday, February 12, 2018

Learn to be a good interviewer

Feb. 12, 2018

Introduction


I am getting better on practice to be an interviewer. This is the seventh mock interview and I worked as an interviewer as anonymous interviewer.

I know that it takes time for me to build up a new skills. So I start early and work on diligently four times a week. And I just finished seven of them.


Getting better is possible


Here is the feedback I got on Feb. 9, 2018 mock interview.


Canada family day long weekend

Feb. 12, 2018

Introduction


It is a busy long weekend. I only spent 2 hours on tennis court on Feb. 12, 2018 from 4:00 pm to 6 pm. It was still chilly but I enjoyed so much to play tennis and still felt that I am very healthy and energetic. I have not run too much the whole weekend until in tennis double match today.


Mock interviews


I practiced over 14 mock interviews through the long weekends. I could not believe that I met so many talent people and then I had chance to continue to work on the algorithm, and also learn so many things through the mock interviews.

Here is the picture to show what I did.




Launch school

Feb. 12, 2018

Introduction


It is another mock interview this Monday 6:00 PM. I had chance to work with a peer and then I was interested in the peer's JavaScript ability. He did have more time to learn JavaScript and then I like to figure out why.

Launch School


I met over five peers to work on FullStackAcademy boot camp. And the peer shared me with his experience, he did research to convert his career to software programmer. He chose the Launch School.


Actionable Item


Look into the courses provided by Launch School. Here is the web link. The launch school is much cheap compared to boot camp. And the student can spend as much as need to go over all the courses. The peer shared with me that he spent over a year to finish all those courses. I just like to say that he is very smart young person who represents United States hard working young generation.

I am so happy to have chance to mock interview with him today. Proud that United States will become much stronger country since those hard working young generation.


Wechat sharing with my family


我上周末模拟面试一个美国小伙子,  31有工程管理经验爱打篮球自己转行做计算机软件开发名牌大学毕业我面试过七八个麻省哈佛转行学计算机参加四个月强化班一万二千美元.
这小伙告诉我费用太高他选了自己控制进度https://launchschool.com/每月200美元他读了一年多这个学习计算机用多种途经他学得很好节省了一万多美元而且学生是全世界课程水平高.  很多中国学生
你说中国留学生如何竞争除非你可以进四大软件公司要么和美国年轻人竞争他们是有语言优势教育优势工作经验.
美国的前途在这些勤奋的年轻人手中我很高兴地帮助他们成长成才.


Leetcode 776: split binary search tree

Feb. 12, 2018

Plan to work on Leetcode 776 in short future.

Here is my C# code. It is easy to figure out the solution after I worked on the similar algorithm, please take a look the algorithm called binary search tree inorder successor to test candidate confidence.

Leetcode 54: Spiral matrix

Feb. 12, 2018

Plan to study Leetcode 54: Spiral matrix python solution. Here is the link.


Leetcode 54: Spiral Matrix

Feb. 12, 2018

Introduction


It is 12:00 PM mock interview. I had to work on Spiral matrix algorithm. So I spent around 20 minutes to write a solution based on my last practice.

I learned the lesson on interviewing.io on January 23 2018. The lesson is that I have to take mock interview seriously. Follow the interviewer. If I am asked to find the alternative solution, then I have to fully use those 40 minutes to come out the solution. Work on it, and define the requirement, and address the issues, come out the design, techniques to solve the problems first.

Code review


Here is my C# code.


Find best position to host the party based on Manhattan distance

Feb. 12, 2018

Introduction


I do not expect that I will learn the algorithm from the peer after the mock interview. Actually it is very good experience to learn that the peer can solve the problem using very good reasoning skills, related to quick select algorithm.

For my understanding, it is like applying counting sort or bucket sort, you decide where to place the position, count how many increments and decrements for each move.


Algorithm discussion


Here is the algorithm.

Follow up 

May 8, 2018

The peer got Google full time job starting this May. I am so excited to get connected to him.

June 19, 2018
Here is Leetcode 296.

One of his blogs:
https://blog.csdn.net/xudli/article/details/49420623

Here is blog about geeksforgeeks.com.
https://www.geeksforgeeks.org/sum-manhattan-distances-pairs-points/

Deletion distance dynamic programming

Feb. 12, 2018

Introduction


It is BC family day and I booked 10:00 AM mock interview. I wondered last night who will practice mock interview in the day time of Monday. I was wondering if I should work on something else, go out to play tennis, walk around the park, go shopping of fresh fruit and vegetables.

I started to work with the peer on the algorithm called Sudoku Solver. It is so much fun to work with the peer on this algorithm. I did one a few days ago on the engineer in silicon valley area, and I like the peer quick thinking and also very good communication skills. Specially when the peer asked me if everything looks good on my side.


My mock interview


I had to solve deletion distance using dynamic programming. What I did is to go over the example first, and then I explained how to solve the problem row by row.

Here is C# code. The peer advised me to optimize the space to O(m + n) instead of O(m * n).





Here is the graph I drew and then I worked with the example to explain the algorithm. I found out that I have more time to explain the algorithm using the graph and walk through the example slowly to explain the algorithm, in case there is any question from the peer, I can stop and then explain more.

I also start to learn that the coding part is less challenge compared to explanation of the algorithm.

Smallest substring containing all unique keys

Feb. 12, 2018

Introduction


It is so much fun to play mock interview. I met the same peer fifth time.

After the mock interview, I gave the algorithm to the peer to solve, and I am busy working on my hackerrank contest algorithm.

Last minute, after ten minutes to give out the algorithm, I found out that I made a mistake on the constraint. The array should include non-negative elements only. And the peer came out the solution I could not understand.

The problem is to find a continuous subarray with the given sum, and then the solution is to apply dynamic programming using O(n) time to get the prefix sum from left to right, and then use two pointer techniques on an ascending array.


Code review


I chose to skip my algorithm, and asked to study the peer's solution. Here is C# solution I like to review and then rewrite later.






Sunday, February 11, 2018

Cut a strip - hard level algorithm

Feb. 11, 2018

Introduction


It is the hard level algorithm and I already spent over 60 minutes to think about the algorithm. I like to make it my favorite hard level algorithm. This is Sunday night Feb. 11, 2018 10:32 PM. I wrote down the blog while I mocked interview the peer.

It is hard but I like it


I like to work on the analysis of the algorithm first. I did just download a few algorithm lecture notes and try to identify what is the algorithm. The algorithm is the hard level algorithm on week of code 36. Here is the link.

Follow up 


Feb. 20, 2018

I like to read the solution and then study some of code submission as well. I looked up all submissions scoring 70 and then I found the blog to read.

Here is the blog of the algorithm.

Idea to solve the algorithm


I just copied the idea from the above blog, and then look into some keywords:
题意
给一个矩阵,可以将其中大小 1 × x (1 ≤ ≤ k) (纵横均可)变成 0,求操作后最大子矩阵和。
题解
  • 如果没有修改,那么就是枚举两行,预处理列的前缀和后就转化为经典的最大子段和了。
  • 现在这个最大子段和问题,多出了一次修改,用 dp 记录一下修改有没有用过即可。
  • 问题在于要在一列的一个区间中贪心地去掉长度不超过 k 的子段,使得剩下的和最大(也就是子段和最小)。这个过程在枚举行的下界时用单调队列维护一下,求出最小子段和。
  • 因为去掉的不一定是列的一部分,还可能是行的一部分,所以要转置后再计算一次。
  • 由于操作是必须进行的,矩阵中所有元素都为正数需要特判,强行去掉矩阵中的最小元素。



How to Think about algorithms - Loop Invariants and Recursion

Feb. 11, 2018

Introduction


It is such a great answer on quora - Is it worth to hire a Google engineer to help me to prepare for Google interview?

I like the web link of Algorithms and Data structure free books. Here is the link. I also find a book to download and plan to read it.

How to think about algorithms?


I plan to read the book. Here is the book link.

Week of code 36

Feb. 11, 2018


Introduction


It is so difficult for me to find hours to work on the week of code 36. But I like to give it a try. Now it is 6:27 PM. I try to push myself to get to spend time to work on hard level algorithm.

I just booked a 10:00 PM mock interview. Now it is 7:20 PM. I like to prepare a dinner for myself. So I will have two hours 40 minutes to spend time to think about an algorithm.

Cut a strip


Now it is 8:20 PM. I have 80 minutes to work on the algorithm. It is hard level algorithm.

Leetcode 780: reaching points

Feb. 11, 2018

Introduction


It is most difficult algorithm I heard. The dynamic programming or recursive solution could not pass Leetcode online judge. I plan to study the algorithm in short future.

Here is the link.

Swift means sweet

Feb. 11, 2018

Introduction


Swift language is chosen by young generation programmers and they like to work on ios app etc. I was explained by the peer through the mock interview. I rated that the peer is one of top performer in my last 160 peers last eleven months.

It is my decision to start a new round of mock interview using ID: beet after I finished the round using ID: apple. I also chose to interview using Swift language, since I practiced one time with a peer using Go, I like to learn new things and stay out of my comfortable zone this round.

This is the first time over 160 mock interview that I met a peer who used Swift in the mock interview. As a matter of fact, he was the first person who asked me to give him time to look at his algorithm before I started to code my algorithm Leetcode 10: regular expression matching.

And also the peer shared his Swift code of Leetcode 10 after I performed my algorithm. And then the peer told me that he solved the problem differently, and I asked him to explain it to me. And then I had chance to learn Swift language from him, and also I had chance to ask question on the implementation. I learned to ask questions and identify the recursion zero time, one time or more than one time in the code. I was so surprised that I just learned a new way to solve the problem. It is an iterative way, and it is to go over pattern string and perfect solution. I really enjoyed the learning.


Swift code


It is kind of sweet for me to learn a new language. I learn starting from my most favorite algorithm. I just could not believe that the teaching and learning can happen so quickly.

Here is the swift code. I added comments to highlight the b* pattern repetition zero time, one time or more than one time.


Leetcode 10: regular expression matching algorithm

Feb. 11, 2018

Introduction


It is 10:00 AM mock interview. I had to work on the algorithm of hard level, Leetcode 10: regular expression matching algorithm. I told that it is not easy to write in 30 minutes, I did exactly 30 minutes, wrote analysis and also wrote the code, fixed the index-out-of-range error, and then passed all test cases.


Mock interview 


I wish that the mock interview platform has some recordings like interviewing.io so I can replay how I did less than five minutes to go over the test case and explained my approach.

I just quickly pasted the analysis I did in mock interview here. And then I will write a few sentences to match my presentation in the mocking interview.


Add caption
What I did is to go over the example with text string "acd" and pattern string "ab*c", and then drew a matrix with text string and pattern string. I did not make the choice, and by accident, I chose the pattern string in the right top corner, and then it is to go over each pattern char from left to right in the row. And also I explained to the peer that I will go over the base case first, which are first row and first column. After that I will go over each row and then I did go over the row on line 72, using text "a" and compare to each pattern string and fill the value with True or False.

Specially I explained the case with text "a" and pattern string "ab*", and b* will apply zero time. So the result should be true. T(0) is the symbol whereas 0 stands for pattern repetition number of times.


Analysis and C# code 


Here is my analysis and C# code. I explained to the peer later on how many practice I went over this algorithm, so many people in the world help me to go over the algorithm. I also watched the peers to perform the algorithm more than five times.

I still remembered that the Christmas day in 2017 a young Chinese graduate student performed the algorithm almost perfectly, I could not believe that he could do it perfectly in front of my eyes, I did go through several times with experienced programmers in the world, how they struggled to write recursive function multiple times. I did ask a lot of questions.

Just two days ago, the peer shared me the news he joined LinkedIn as an intern through the wechat. It is a side story. But I just wrote down to remind myself that teaching and learning is so efficient and once I know that a young graduate student can perform, I believe that one day I also can perform as well.




Saturday, February 10, 2018

Say hi to the city of Seattle

Feb. 10, 2018

Introduction


I have met over 10 people from the city of Seattle in anonymous interviews last two months, however I only met less than five people in the city of Vancouver area.

Every weekend I have chance to meet people from the city of Seattle, and also I have chance to learn so many exciting things happened in the city.

I met a programmer from the city of Seattle, and then I advised him to play one of Hackerrank contest. It is fastest and easiest way to get the feeling to algorithm and data structure, and then you will think about the algorithm and data structure all the time in your daily activities.


Say hi to New York again

Feb. 20, 2018

Introduction


It is true that I met a peer from New York this morning 12:00 PM mock interview. I already met over 10 people from New York. I started to learn one thing a time from people working in New York industry.

It is fun and also people are more active to reach out to other people as well.

New York style


I did hear a few things about New York. How things work in the city of New York. Today I also learned a few things through discussion of JavaScript coding of a H-tree algorithm.

Here is JavaScript code.

Since the peer told me that he has over 10 - 12 years ruby on rail experience, so I asked him the question how he designed the JavaScript function, basically it is like functional programming style. const drawHTree = (x, y, length, depth) => {. 

I asked the peer to extract variable top_y, bottom_y, left_x, right_x four variable, and then I asked the peer to write to DrawLine the length of line and declare a variable for totalLines. 

I asked the peer to  count how many H-tree by steps, and then he quickly came out the time complexity. 





How to make a successful mock interview as an interviewer?

Feb. 10, 2018

Introduction


It is the sixth mock interview on the second anonymous platform, so I had chance to meet programmers from top ten companies in west coastal area and also graduate students from top universities, and then I had chance to get some feedback about the algorithms I choose, and the behavior issues I have to correct.

First of all, I should give the interviewee the agenda, including how many algorithms I should give. This is the advice I got from Feb. 9, 2018 mock interview. I do not want to scare the interviewee when I ask the interviewee to stop the first algorithm, and I like to move on to the next algorithm.

My goal is to test how confident the interviewee is, how good the interviewee is on algorithm and data structure problem solving. I will continue to ask and then see if I can find any major issues through the interviewee. Since the interviewees are with experience both sides, and also with very good education, so usually I just pay more attention to learn something through the experience.

People varies in terms of soft skills, and learning new things outside the work. Sometimes people can not hide if they do not practice algorithm and data structure long time, like catching up in a month of two.

Algorithm


The interviewee asked me where to find the resource about the algorithm I asked in mock interview. I know that the interviewee is very confident and also independent thinking. So in order to prepare an algorithm to be my mock interview algorithm, I also try to build a profile for the algorithm. I share the algorithm float number and operations on the stackexchange.com website. Here is the link.

I continuously study one algorithm called spiral matrix, Leetcode 54. First time I learn that it takes so much time for me to catch up so many ideas and then I know how smart people are to get the good idea to survive in a mock interview and write a perfect working solution in ten minutes.

Yesterday the interviewee took over ten minutes to read the problem Leetcode 54 and came out the idea, and then he tried to use extra space to avoid so many edge cases. I really like the idea, it is something I am looking for in mocking interview.

I honestly told the interviewee yesterday that some one did much better than him, passed through all four algorithms I gave to him in first 35 minutes, and he did 30 minutes system design interview as well. If you work for a big company, basically you are competing with your coworkers. The anonymous interview is supposed to be hard, difficult to pass the interview. Do not get frustrated if you get low rating. I just make sure that you are guided to the optimal solution, so you learn something and do not waste time on mock interview.

The precondition is that I also have to learn the mock interview algorithm from all the interviewees, I have to build depth and breadth of knowledge of the algorithm.

What I have learned as an interviewer


I did find one thing through the mock interview. I have to learn how to take turn to express my idea and also try to catch the right time.


Educative.io

Feb. 10, 2018

Introduction


It is another 10:00 AM mock interview. I had good time to write a recursive function called minimum path sum from root to leaf node, and also I had chance to watch the peer to perform a recursive function using depth first search.

Advice


One advice I got is to watch courses on educative.io. The peer took two courses, one is algorithm, one is system design.


Friday, February 9, 2018

Leetcode 54: Spiral matrix - based on directions

Feb. 9, 2018

Introduction


I keep learning the spiral matrix algorithm through Leetcode discussion, and then I came cross the discussion of Leetcode solution based on the directions.

Here is the discussion note I like to share. I read carefully about the analysis and then write down and make some modification, so I can follow closely the thinking process of the author.

Analysis based on directions


I like to go over the discussion here as well. Here is the C# code. Also I like to add this solution to the question I asked on stackexchange.com so that I can get some feedback later on.

Thursday, February 8, 2018

Leetcode 54: Spiral Matrix

Feb. 8, 2018

Introduction


One more solution is here based on using two variable to switch direction clockwise. I read the idea from Leetcode 54 discussion, and then tried to write one using C# language.

One of ideas is to go over as many Leetcode discussion as possible, and then I will vote the idea I like and actively share my feedback. Because I like to use this algorithm for my mock interview as an interviewer, I like to do as many research as possible.

Please write at least ten ideas using C#. Be well prepared and learn one algorithm very well. I can  use the algorithm to tell who is real talented programmer in the world.

Using two direction variables

Here is C# code.


Leetcode 54: Spiral matrix - think recursively

Feb. 8, 2018

Introduction


It is my idea how to train myself in the practice. It is to involve the discussion of Leetcode. Every algorithm I should give out 10 votes for 10 different ideas, and also write C# code based on the idea.

I did some research based on my practice of Leetcode 301 recently, and I found out that my practice has some issue. And I wrote a blog how to learn a hard level algorithm on Leetcode.com.


Recursive solution


I studied the solution today, and I like to write a C# code based on the idea. It is the great warm up of recursive function, and also nice to review base cases in the design of recursive function. Here is the C# code.