Monday, June 25, 2018

C# HashSet class

June 25, 2018

Introduction


It is the algorithm called Sudoku solver, my favorite one. I did have a mock interview on June 23, 2018. I wrote C# solution and came cross the question, do HashSet class have Remove API. I notice that it is time for me to spend time to memorize all APIs of C# HashSet class.

HashSet class


There are so many things to do once I decide to start to memorize HashSet class.

I plan to study IEqualityComparer interface, and then I read HashSet source code.

I will write down all API here. It is important to try to memorize all API first. And then I should come out questions to ask about class design, implementation detail.


Follow up 


7 constructors

HashSet<T>()
HashSet<T>(IEnumerable<T>)
HashSet<T>(IEnumerable<T>, IEqualityComparer<T>)
HashSet<T>(IEqualityComparer<T>)
HashSet<T>(Int32)
HashSet<T>(Inte32, IEqualityComparer<T>)
HashSet<T>(SerializationInfo, StreamingContext)

Properties

Comparer
Count

Methods

Add(T)
Clear()
Contains(T)
CopyTo(T[]) - it is convenient to call - to array is so easy
CopyTo(T[], Int32)  - copies the elements of a HashSet<T> object to an array, starting at the specified array index
CopyTo(T[], Int32, Int32)
Static - CreateSetComparer() - it takes me more than 10 minutes to read - ask why it is static?
Equals(Object)
ExceptWith(IEnumerable<T>) - Removes all elements in the specified collection from the current HashSet<T> object.
Virtual - Finalize() - understand why it is virtural ?

GetEnumerator() - Returns an eneumerator taht iterates through a HashSet<T> object
GetHashCode()-
GetObjectData(SerializationInfo, StreamingContext)
GetType() - Gets the Type of the current instance.
IntersectWith(IEnumerable<T>) - Modifies the current HashSet<t> object ot contain only elements that are present in that object and in the specified collection.
IsProperSubsetOf(IEnumerable<T>) - Determines whether a HashSet<T> object is a proper subset of the specified collection
IsProperSupersetOf(IEnumerable<T>) - supset
IsSubsetOf(IEnumerable<T>)



20 minutes study


Plan to spend 20 minutes quick study of five categories of types

GetType() - Gets the Type of the current instance.
Spend 10 minutes to read the code using GetType()


Classes -> System.Object
Value types -> System.ValueType
Interfaces - System.Object
Enumerations - System.Enum
Delegates -> System.MulticastDelegate


10 minutes to read

IsProperSubsetOf API docuement is here.



Questions asked:

Why CreateSetComparer() is static?
Why Finalize() is virtual?
what is proper subset? subset vs proper subset?

Min to win it - week of code 38

June 25, 2018

Introduction


Life is so busy. It is hard to get into a fight against time out issue in the algorithm problem solving. I know that I have to get more training through hackerrank contest.

I spent over one hour to work on the code. I just could not figure out how to get linear time complexity going and then I decided to move to next algorithm around 3:00 PM this afternoon.

Time out so many test cases


Here is the image to show so many timeout test cases.


Sunday, June 24, 2018

I am back to hard working

June 24, 2018

Introduction 


It is so hard for me to go back to be a hard working programmer. It took me more than three weeks. I spent two days sitting at home the whole weekend, worked inside home office. First day it was Saturday, I did not want to go out, but I did not work on week of code 38 either.

Second day, I told myself to hold on everything just to play week of code 38. I only wrote first two algorithm less than three hours, one friend asked me to mock interview with him. It was maybe 5PM, I had discussion with him until 6:40 PM.

I was so patiently to go back to work on the third algorithm. Now it is 11:47 PM. I only worked on the contest less than 12 hours. Now I finally figured out the third algorithm even though I had to go over discussion panel to read all the discussion to figure out two user cases. I made it from score 0 to full score.

It took me almost one hour to read the problem statement of A time-saving affair, after one hour just thinking about the algorithm, I started to code and try to make any point if I can.

Love is patience 


Since I love algorithm and data structure challenge, I learn to be so patient to myself. I just let myself to enjoy the time to think, time to write code, hold on worry about scoring zero, and read the problem statement and search discussion for tips patiently. I know that the English wording in the problem statement is questionable. I just need ideas to think about the constraint different viewpoints.

I just gave myself enough time and let my brain think and try to write some code, simplify and make it work.

Now I push myself rank to top 25%.

I need to plan ahead and work in weekdays, and allow myself to work on hard level, advanced level and expert level in weekends.

I really enjoyed the time to write around 100 lines of code for the medium level algorithm. Finally I am back to normal, hard working, do not think about anything else.




I should write a medium/ hard level algorithm daily, otherwise I am very easy to get lazy.

Action Items


Julia, you should try to work on hard level and advanced level algorithm after the contest. Try to get out of comfortable zone and start to learn some hard level algorithm.

Follow up


My feelings of working on medium algorithm:

I need to expedite the thinking process. It is too slow. It is just a medium level algorithm.

I could not pass all test cases since timeout on second easy level algorithm.

If I like to pass onsite interview from SDE III, I have to push myself hard when I practice.

In terms of Hackerrank contest, I should be able to solve medium level algorithm without any headache. Those long hours to work on one medium level algorithm is alarm for me, I have to come out a plan to work on something. It should be less than two hours. 15 minutes to think about problem at most, not over one hour.

Replay of the last hour of contest


I finished the code passing the sample test case, but scored 0. I had only less than two hours to the end of contest. Maybe it is one hour only. I tried to push hard to figure out the issue.

I read the problem statement for a few times. And then I started to notice my design issues.

I already made sure that there is no dead loop. I still missed the issue, that is the best time to play contest after long hour. I showed up determined, very careful to scrutinize all possible issues.

I just like to use two graphes to show those kinds of experience are really healthy to train my mental toughness. I think that all the training and good habit to deal with uncertainty helped me in those 20 to 30 minutes to push hard.

I just showed those two images here and then memorized those hard working moments. The thing I could control very well, I should focus on. I start to realize my value of time of one hour in this critical moment. From bottom 15% to top 25% in the one hour.


Onsite interview algorithms

June 24, 2018

Introduction

It is hard to pass phone screen. Once it is onsite, I think that most of people will have no clue to stay there sometimes, even smartest person will fail somehow. I came cross this post to discuss his experience. Here are the type of questions showing onsite.

DFS
BFS
DP,
binary search
sliding window
Topological sort,
two pointers,
bit manipulations,
data structure to implement LRU, LFU, stack/ queue, Trie, Sorting, design a data structure
(

Share one post after a few month break on quora.com

June 24, 2018

Introduction


It took me more than one hour to write a post on quora.com. I like to share something after a few months break. It is not too hard but it is not too easy. I try to make sense on each good thing, I write 10 good things. It is kind of too generic topic, 10 good things. Maybe I should write 3 good things next time, so I can save some time to work on something else.

what are ten good things after playing hackerrank contests?


I put together a question and then write an answer for it with supporting documents, I did add foot notes with more than 8 blogs I wrote before related to contests I played.

Here is the link on quora.com.


Artificial intelligence article

June 24, 2018

Introduction


I try to be a good friend to support those people staying in California and looking for a software engineer job. I also learn something every time a friend chats with me and update me some article to read.

I got an article to read and I like to scan the article and look into a few thing. Here is the article link.


20 minutes study


Luke Zettlemoyer, a professor at the University of Washington

AI Lab called Deep mind.

Study Linkedin profile - Marcelo M De Barros

June 23, 2018

Introduction


I came cross the message since I follow the profile of Linkedin from Microsoft principle group manager Marcelo. It is so inspiring to study the profile with the summary.

I like to make similar presentation like Marcelo does. I believe that he has great taste of art.

My most favorite one is to read his coding blog. The link is here.

Saturday, June 23, 2018

Learn from Naomi Osaka

June 23, 2018

Introduction


I gave myself several hours to study WTA ranking top 100, I did come cross some new faces and then look into a few players. And then I spent over 50 minutes to talk to a friend. And then I decided to study the player Naomi Osaka, how she tries to get into top 20 ranking.

Interviews 


It is fun to watch some interviews. I like to cheer myself up this Saturday. I do not know what to do in terms of study of top 100 ranking.

Here is the video called Naomi Osaka - Roland Garros Tennis Channel Desk visit.

1:11/ 2:40
What do you learn from yourself from victories?
Answer: Kind of surprise.

Plan to read the article called Naomi Osaka is the coolest thing in tennis.
Plan to read the article 10 minutes called

Naomi Osaka success shows tennis can be a better spectacle without seeding

Try to be consistent - Train very hard off the season - paying off - unsatisfied everything I do -
6:00 - train very hard off the season
7:00 -
8:00 -
9:00 - celebrate crazy way is kind of disrespect to the opponent
       
10:00 -
11:00 -
12:00 -
13:00 -
14:00 - 

10 minutes video:
BNP Paribas Open 2018: Naomi Osaka Champion's Press Conference

1:10           lose points depends on nerves (?)
2:09/10:49 psycho myself out, nerve get checked
3:31           ...
4:27           habits? think - more confident will win again
6:00           my goal - more focus each match
8:23           hit harder? ...         

Here is one of videos I like to play a few times.

Follow up

Sept. 8, 2018 6:11 PM

I just could not believe that I just watched Naomi won US open 2018 champion through youtube.com video.

Ten good things about playing hackerrank contests

June 23, 2018

Introduction


It is time for me to write down an eulogy about Hackerrank contest. I spent a lot of time to check in all source code for each hackerrank contest last week, and I just wondered how come I played so many contests through last two years.

It takes me hours to go over those algorithms, blogs. I could not believe that I did write so many algorithms, over 100 algorithms for over 25 contests.

Hackerrank contests



I used to play a lot of hours tennis sports. I know that people will ask me how many hours I have played. 500 hours or 1000 hours. I like to get those hours for Hackerrank contest.

I like to give thanks to Hackerrank and those sponsored companies. I never made it to any of those companies. I try to play for Canada, play for myself, and play for fun.

It is a new life style when I chose to play hackerrank contest one after another one. I could not remember I spent so many weekends to play contests.

Here are some facts:

1. 5 medals, including a gold medal, two silver medals, 2 bronze medals from March to June 2017.
2. A few calls from local software companies first time contacted me from July 2017 to Oct. 2017. 
3. April 2018 I got contact by a company, May I got a phone screen without code screen.
4. I play very well a lot of places. I think that I play Hackerrank, Quora.com, Blogger.com, Code review on stackexchange.com, mock interview platform, also social websites: twitter.com, instagram.com, facebook.com, google+.

Here are my thoughts:

1. I want to be an excellent algorithm and data structure teacher.
2. I want to write code in the weekends. Keep myself busy.
3. I try to bring some topics for my coding blog, contest is really great activity.
4. From April to June, I had more time to play contests since I also play a lot of sports, tennis. 

We got so many platforms to play, somehow I just demonstrated to people that every one can do such a good job if you can work hard continuously over years. I also need to remind myself to work hard, do not give up.

Best thing is to love writing software after those contest experience. I just could not believe that I enjoy so much to write software at work. I could not control to rewrite if I have time, since I have better idea to implement a solution.

10 good things about playing contests


1. No more phone call, chatting.
2. No more shopping around. I try to cut down to minimum.
3. No worry about weather. Stay at home office all the time.
4. Enhance the ability to do research, enjoy exploring new topic of algorithm and data structure.
5. Know more players in the world.
6. New way to meet people, those people loving the competitions.
7. Do not need money to play. Only need free time.
8. Enjoy long hours work, I documented each hour. Work on a check list.
9. Build strong interesting to write code
10. Learn to play with limited time, follow up with code review questions, experience learning through more than 12 months.


  

Byte to byte - Algorithm and data structure problem solving coaching

June 23, 2018

Introduction


I met a young graduate student and we worked together on mock interview algorithms 90 minutes. I worked on Sudoku solver, and he worked on binary search Array index and Element equality. He recommended me to watch Byte to Byte video on youtube.com.

It is such a good conversation with the young graduate, we did talk about a little theory about binary search algorithm, common mistakes, base case, dead loop, and lowest index, recursive function vs iterative solution.

And we talked about more about internship, onsite interviews. I really learn a few things about young graduate  student, a very good engineer and quick to write and work on coding all the time. Compared to him, I am kind of slow to get along with the peer, and not so good to work on a test case, and try to figure out things on the fly, make thing work.

One fact is that I practice binary search last 6 month over 50 times through mock interview, the peer only did once. I did see a lot of issues in the coding part. But I also learn how to judge a person with good thinking process and how to take hint and move forward. I treat the algorithm problem solving likes sports, there is no way to avoid hard work. Embrace it.


Research 


Academic research is such a great topic and I wish that I have time to get into more on a topic.

One video to watch


Here is five minutes called "Increasing your creativity and solve any coding interview problem".

Spend 15 minutes to go over all possible solutions first. We should not go to optimal solution right away.

Take the time to really think and even wild ideas. What sort of things will work, what sort of things will not work.




learn from one engineer - Tan chao

June 23, 2018

Introduction


I read the article on 1acre3land.com, and came cross the name called 覃超.

20 minutes study


Here is the video I watched. 5 minutes video is here. 25 minutes video is here, the topic is things learned in the facebook.

Book to read: Find strengths 2.0

One argument is to work hard, you can do the best.

Every one should find yourself the strong five personalities.

Advice:
Prioritize your tasks
Have your vision
Keep practicing
Watch replay


Reading time - 1point3acres.com

June 23, 2018

Introduction


I understand that I need to catch up a lot of reading. One time my coach showed me how he came out an algorithm for me to work on since he saw a post on 1point3acres.com, so he just changed the phrase. The algorithm is here.

Saturday reading 


Here is the gist I created for the article to talk about software programmer interview and computer science PH.D. program.

A few arguments to think about 


Here are some good arguments to think about from the above article.

Argument 1:

很早之前在B家工作时,就与同事们有一个传统,就是保持市场竞争力的最好方式是出公司面试,看看自己的技能和经验在市场中的价值, 以此判断自己在行业中的位置,是被淘汰还是引领。所以,面试硅谷并不仅仅是为了执行自己的决定,也是一种校正职业方向的方式。

Tennis sports and friendship

June 22, 2018

Introduction


I make a new friend so quickly before I even notice. Last time I went to the tennis court to hit against the wall, the young man next to me told me that he played tennis with me before last year, I have no clue maybe he lied. So I asked him to rally with me on tennis court since I like to run more on the court.

I learn to respect the partner time and also give feedback nicely. I asked him to put more topspin and therefore he can place the tennis ball just before me, one meter away, not running too hard, and show him to put more windshield wipe on the swing. Sometimes I just coach those friends to quickly be my professional hitting partner. He came to the court multiple times a day in the weekend, I told him that I could not come the morning and afternoon because I need to work at home. I need to have 30 minutes workout, run a lot hitting on tennis court.

Old friends also start to like me since I share the tips and show up on tennis courts more often. I am open to stay alone and hit against the wall at the beginning, hunting for hitting partner for next 20 to 30 minutes.

I still remember one advice from the senior player, he told me once there are 12 courts, every five minutes there is change on one of courts. I am just very patient. This can apply to those job seekers on software engineer area as well.

I have done a lot of study on tennis sports, so when a friend told me that she fell on the tennis court, and her partner also fell a few times. He showed me how he fell when he walked backward. I took a few minutes to explain how to run backward using correct foot work [Ref. 1] to prevent falling, expand the center of body weight in-between two legs widely separated.

Today I went to court and started to play against the wall. I was invited to play a double match. I believe that last time I shared the safety tip, they like my advise. After the match, I start to rally against another player.

Friendship


I think about those friendship on tennis court. I play tennis with a lot of people, some of them put a lot of hours on tennis court this season. I need to work on algorithm and contest, I usually cut time to maximum two hours every time. I only show up a few times a week.

We used to spend hundreds of hours together last few years. I cannot spend hundreds of hours on tennis court this summer.

Summer is such great time in the city of Burnaby central park. I need to lose more weight and need to get those friends help me to stay on the court, play harder and run for each tennis ball.

Editorial note:

What happen to those colored sentence?
I wrote the blog first. And then I read again in the second day, I like to make correction. I added some content to make the blog more meaningful. So I highlighted those additional clauses.


References:

1. https://www.optimumtennis.net/tennis-footwork.htm


Friday, June 22, 2018

week of code 38

June 22, 2018

Introduction


It is time for me to work on week of code contest again. I miss those medium level algorithm and those long hours to work on algorithm and try to advance the ranking. I like to dedicate at least more than 8 hours on the contest.

Life can not be that hard. As long as I try to solve hard and advanced level algorithm every week, I will learn something and also fully enjoy the time to work on those algorithms.


Thursday, June 21, 2018

Day five - hard level algorithms

June 25, 2018

It is time for me to read hard level problems 10 algorithms a time. I just could not believe that I will read the problems first, and come back any time if I like to think about more how to solve them.


668 40.7%Hard
675 26.9%Hard
679
24 Game    
38.8%Hard
683
K Empty Slots    
33.5%Hard
685 27.6%Hard
689 41.4%Hard
691 35.1%Hard
699 38.1%Hard
711 41.9%Hard
715
Range Module    
30.9%Hard

Day four - hard level algorithms

June 25, 2018

It is time for me to read hard level problems 10 algorithms a time. I just could not believe that I will read the problems first, and come back any time if I like to think about more how to solve them.


716
Max Stack    
36.9%Hard
719 27.7%Hard
726 43.4%Hard
727 31.2%Hard
730 35.4%Hard
732 49.6%Hard
736 41.9%Hard
741
Cherry Pickup    
24.1%Hard
745 26.0%Hard
749
Contain Virus    
40.3%Hard

Day three - hard level algorithms

June 25, 2018

It is time for me to read hard level problems 10 algorithms a time. I just could not believe that I will read the problems first, and come back any time if I like to think about more how to solve them.


753 40.8%Hard
757 35.1%Hard
759 53.3%Hard
761 43.5%Hard
765 48.3%Hard
768 43.4%Hard
770 42.5%Hard
772 40.4%Hard
773 46.3%Hard
774 33.0%Hard