Showing posts sorted by relevance for query hackerrank contest. Sort by date Show all posts
Showing posts sorted by relevance for query hackerrank contest. Sort by date Show all posts

Saturday, June 23, 2018

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.


  

Wednesday, June 28, 2017

Common mistakes talk

June 28, 2017

Introduction


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

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

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

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


Common mistakes 


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

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

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


Related work from Hackerrank contest 




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

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

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

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

Learn to count algorithms


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

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

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

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

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

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

Monday, November 7, 2016

HackerRank NCR codesprint review

Nov. 7, 2016

Codesprint:
https://www.hackerrank.com/contests/ncr-codesprint/challenges


Julia was so motivated to spend 2 days in the weekend to work on the codesprint, she only did one shopping trip to Burnaby crystal mall, less than 2 hours. Rest of weekend, she worked on the problem solving.

Julia reviewed the article about HackerRank contest and how to play better:

https://goo.gl/IHeEoi

Her favorite note in the above blog, item 4:

Even if you are not world class competitive programmer, you still have a chance to get into top 50 or even higher. The minimum goal is to get into top100, which is like usually about top 2–3% of all competitors. Being in top100 is great and sounds really good. 

The major factor to achieve the goal is a combination of problem solving skills, online research, dedication and persistence. First read all the problems and start solving them one by one from the easiest one. First solve the ones you can tackle without any research or long thinking, just to mark them as done and get motivation to tackle harder ones.

Julia did some research on this NCR contest, in top 100, even around 100, some of them are ICPC contest winner, score range is around 200 out of 430. 

Julia's score is 62.76, 480 out of 2621. 

Facts:
1. Julia likes to work on those hard algorithms, last 3 of 8 algorithms. She thought that she could make 10 from each of them. But it was too late when she read the problem statement. She only had 3 hour left to 12:00am in the middle night of Sunday. 

Lessons learned: 

Do not work on ideas taking a lot of time to code; even prototype is questionable. Treat it as a contest, play to win, not play to learn. 

48 hours contest, a lot of algorithms - 8 of them, total time to work on is 16 hours, 8 hours a day. So, give each algorithm 2 hours a time. 

Spent 6-8 hours to score 6 out of 20 on spiral message. Simple mistake of understanding problem statement, and base test case: one line, one row failure. 

Should be more confident on hard algorithm - game of numbers. Less than 1 hour to score 15 of 50, but gave up bug fix. So close to perfect solution. 
So, if Julia has more experience to play HackerRank contest, she should try to make it at least 100 of 430. And also, she can spend less hours to work on the contest, and spend 1 - 2 hours a day on sport activities in the day time. 

Do not think about past contest - Warlmart codesprint, 24 hour contest, Julia spent time to bet on a hard problem (score: 100) until 4:00am, and scored 0 of 100. 





Monday, February 27, 2017

Are programming competition a good use of time?

Feb. 27, 2017

Introduction


Julia came cross the article after she studied hackerrank university codesprint #2 leaderboard.

Argument No. 1 in the article  

Competitive programming promises even more glory. Win enough contests, and you get an interview at Facebook or Google, where they ask you… you guessed it… more algorithm coding questions!


Argument No. 2 in the article 


By doing programming contests, you gain an intimate understanding of data structures and algorithms and their complexities. While your colleagues vaguely know the difference between a depth-first versus a breadth-first search, you develop a much deeper intuition. You will never forget that one contest where you used DFS instead of BFS, causing your solution to time out.

Fact 1 to share 


Julia won 4 bronze medals in last 12 months, and also played a few other contests as well, here are the details: 

4 bronze medals: 

university codesprint 2  (1247/ 6587) Feb. 2017
Week of Code 27             (1643/ 7476) Dec. 2016
world codesprint 7         (863/ 5649)   Sept. 2016
world codesprint 6        (1168/ 5270)  Aug. 2016

contests: 

NCR CodeSprint                 (479/ 2617)   Nov. 2016
OpenBracket CodeSprint  (482/ 2448)  Oct. 2016
Stryker CodeSprint             (174/ 1929)   Sept. 2016

Fact 2 to share

Julia worked on the queue and caused a big issue like timeout, she wrote a blog talking about sinking sand - a test case is rock to build on algorithm. She learned the lesson of BFS using queue, over 4 hours work ended up scoring 0.   


Argument by Google director of research - Peter Norvig

Is this a valid argument? Winning at programming competitions is a negative factor for being good on the job.


Argument 3 in the article

Given the amount of time it takes to master competitive programming, one naturally wonders: is this really a good use of time? In a contest, you are ultimately solving problems that other people have solved already, so nothing new is being produced. Although solving a contest problem is satisfying, I find it a lot more rewarding to build projects or apps with my novel ideas.


Competitive programming 

whole weekend one medium algorithm

To play a contest on Hackerrank, Julia calculates some math. She has to dedicate herself whole weekend in order to get a medium algorithm done. She has to entertain herself first, play some music, lookup her ideas by Google, write some simple idea to play against hackerrank test case, until she warms up with the algorithm. Sometimes, it takes 5 - 6 hours until she failed so many times and then she understands the problem - what is the real challenge in the problem statement.

code review catching up more

All those hours and labor build up her character, she never experience this kind of research before. Over 10 hours, she makes something happen, solve a medium algorithm. Sometimes a medium algorithm can take her a few days after the contest. Since Nov. 2016, a few times, she has to continue to catch up more research after the contest, and then work on codereivew.stackexchange.com, get some help and find something more interesting to continue.

Julia learns to work on one algorithm a time, and also has to learn to let it go one a time. She knows that she will forget the algorithm completely, it does not matter how hard she intensively trains herself in the contest/ after the contest, and she needs to relearn it one day. Only thing left is something surprising, her new character still trying to mold, the strong determination to solve the problem. The will, or the intuition to try new ideas, relentlessly. That is something different she could not find in the training of Leetcode algorithms. Julia was surprised that she continuously improves over last few months.


Hackerrank contest  algortihms 


Things Julia should have done are to evaluate those easy, medium algorithms in past 10 contests on Hackerrank; Do those algorithms shape her very well as a sports programmer,  what are atlernatives? Julia does not like the inactive learning, by memorizing, she likes more about competition, with time limitation. 


Monday, September 26, 2016

HackerEarth: algorithm tutorial and problems

Sept. 26, 2016

Julia has some difficulty to handle medium, advanced, hard and difficult algorithm on HackerRank contest world code sprint, so she is actively seeking ways to improve.

Try this one - HackerEarth, at least read each algorithm and find typical problem sets; if need, she can quickly jump into the code. She tries to shorten the time from learning the algorithm to working out an algorithm in 8 hours. So she can compete in the contest.

It is hard to compete in the contest right now, to cover her weakness, she has to dedicate a lot of time for a medium level algorithm. She has to give up weekend sports activities, has to focus on the contest whole weekend, nonstop.

One algorithm a time. One contest a time.

It does not matter how hard Julia has to work on contest, at the end of day - more than 8 hours work, she has to be able to come out a solution for a medium algorithm on HackerRank contest.

The contest problem solving is very similar to the work environment; 48 hours is much better than 24 hours. Julia likes the challenges, she just likes to compete, also she thinks that it is very healthy to compete, so she can improve performance in short time. She could not learn these from the work.

HackerRank is very strict on scoring, therefore, Julia is pushed so hard to bring out her best talent, relentless trial and errors, patiently through 8 hours a time.

Here is the website:

https://www.hackerearth.com/practice/algorithms/dynamic-programming/introduction-to-dynamic-programming-1/tutorial/

Recommended by
https://goo.gl/K3iYRY

Sunday, March 5, 2017

Code review: Lucky number 8

March 5, 2016

Problem statement

Introduction


Julia had a few submissions in the contest, she tried 12 submissions. Scores is an interesting array like this, [0, 2, 1.8, 3.6, 10.8]. The final version in the contest, a C# practice in the contest, scored 10.8 out of maximum score 19.80 30.

Lucky number 8 is the medium level algorithm in the week of code #28, Julia took the recursive function as an approach, in order to score more points, she wrote more than 450 lines of code.

Julia did not have too many choices in the contest, the dynamic programming approach is too difficult for her to figure out. Actually she was math major graduate, and then she just enjoyed the workout on this analysis. She was writing a "book" (a joke to verbose coding), actually computer science on hackerrank contest taught her a lesson - to be thrift on time to write code, if she can be ...

Julia spent some time to review hackerrank contest performance  and then looked into the issues of week of code #28, she took a look at the algorithm submissions, she was so surprised, my God, it is such a great workout on recursive function. This is like sports - but it is a time-consuming marathon. This is her first time to write a recursive function and spent more than a few hours, and experienced a little success. Cheers! Julia, good job, even it is 10.8, 30% of maximum score 30. Julia likes to call this algorithm with this submission with a beautiful name by Vancouver islands: Tufino, a vacation place she should take instead of going back to China, a popular summer place to visit whales from touring boats.

Today, Julia likes to show herself how to score maximum score. Learn a dynamic programming after she learned the lesson through the contest.

The most important is to work on the example 968 and figure out how to solve the problem to get the answer 3.

Lesson learned


450 lines of code using recursive function cannot beat 20 50 lines of code using dynamic programming. But Julia also learned the lesson through practice, not at work. That is the importance of practice!

Facts:

In order to score more points in the contest, Julia continuously wrote more code until 450 lines. She had determination to make more points, she showed her passion to solve the problem.

Actionable Items


1. Read editorial notes:

In this problem, you are given a sequence of digits of length . You have to find the number of non-contiguous subsequences, such that the number formed by their concatenation is divisible by .
Observe a bit,
The number is formed by concatenating the non-contiguous subsequences, which implies that the number itself is a subsequence and vice-versa.
So the problem boils down to counting the ways you can make a subsequence divisible by . This can be done by Dynamic Programming.
At any position of the sequence, you need to consider two cases:
  1. Concatenate the digit at the position with your current subsequence and move to next position.
  2. Leave the digit and move to next position.
The idea can be coded with states: Current position and Remainder of the subsequence modulo 8.


2. Check all Google's employees' submission on this algorithm:
Study Java code first, write C# solution with comments.

Work on frequency table to help understanding the algorithm:



Read the above table, we can tell that numbers: 96, 8, 968 are 3 numbers to be divisible by 8, and we found the answer. Is that easy to follow this frequency table?

C# code for Code review is here. Extract a function, make other changes, this version of C# code is better for review, here.

3. Google keyword search:

states? Current position and Remainder of the subsequence module 8

4. Dynamic programming vs recursive function - check stackoverflow.com


Code review


Plan to make the code more meaningful, and then post a question on codereview.stackexchange.com.




Sunday, October 16, 2016

HackerRank contest pressure and countermeasures

Oct. 16, 2016

Just a quick summary, music, dance, sports, with the art to mix them by Adias commercial, Julia found her way to release the contest stress by watching the video:
Garbiñe Muguruza: Episode 3: Keeping Happy


Here are more details:

Julia spent Saturday on Oct. 16, 2016 to work on one algorithm, she finally made full score 40 of 40 after 10 hours struggle - keep scoring 0, until she could not believe that she won two bronze medal of HackerRank contest.

As a reminder, she always remembers that tennis sayings, every one knows how to play tennis, but mental is most important part.

She went back to read the problem statement of the algorithm, and noticed that she should take advantage of expeditures range 0, 200, and used bucket sort. She made it full score after 1 hour coding.

Here is the problem statement.


Second day, she felt pressure and tried to go back to work after she waked up, even it was 5:00am; but then, she decided to relax with some entertainment.

Here are the videos:

1. How to celebrate win?


2. Garbiñe Muguruza

Garbiñe Muguruza: Episode 1: On Court


Garbiñe Muguruza: Episode 2: Off Court


Garbiñe Muguruza: Episode 3: Keeping Happy


(tennis can be very demanding, but leaving everything behind, just having fun. )

4. #CreateYourMark: Hit the court with the stars of Roland Garros


5. Ana, Caroline, Andrea and Tomas Berdych Create Noise in Melbourne



Actionable items:

Julia scored the HackerRank contest Open Bracket 60 out of 250, worked on two algorithms first day of contest; she likes to push herself to full speed starting from 9:25am, score 2 more algorithms if possible.

Now, 10/16/2016, 9:25 am, she ranks 401/ 2001.

Play to win!


Sunday, May 7, 2017

Rookie 3 on Hackerrank

May 7, 2017

Introduction


It is great morning of the Sunday, Julia woke up around 7 am and she decided to get up at 8:00 am and worked another hour for Rookie3 since the contest ends at 9 am PST. Last night she was so tired 10 minutes before 12 am, she knew that she had to go to sleep, stopped to work on Rookie3 algorithm called Culture Difference. She made 5.5 points out of 55.

Julia tried to get smart on the contest, she went out for a tennis sports around 1:00 pm last Saturday, and then come back to work on the contest around 5 pm. And then she took one hour break from 8:00 pm - 9:00 pm, and came back to work on after 9:00 pm - 12:00 pm. She learned to take more breaks and also took care of contest activities.


She could not believe that she stumbled on the algorithm Max Score and could not score more than 3.5 out 30. She just reminded herself to keep learning recursive if that is only thing she could figure out to solve the problem.

Contest review 



Here is the contest progress report at 8:53 am May 7, 2017, 7 minutes before the end. 


Culture Conference Algorithm


It is a long journey from 59.00 points to 140 points. Learn one theory behind the algorithm in the contest a time, now it is a domination set show time.

Julia did not know one of the algorithms is using minimum dominating set based on the editorial note. The dominating set was such a hot topic back to her Ph.D. study, but she never had a chance to write any graph algorithm to practice by herself. Here is the journal paper written by professor Jie Wu and Fei Dai. This is a better link to read the paper quickly.

Julia went to bed still thinking about the algorithm "Culture Conference" around 12:00 am, and woke up around 7 am and still thought about ideas to try to gain a few more points on the algorithm.

This is a really testimony of good relationship between hackerrank contest and academic research. But Julia did not know what she tried to work on is a dominating set, she tried to google but had no good keyword to search in the contest. She took a few graduate courses on network protocols in her Ph.D. study from professor Jie Wu back to year 2001, but she did not have the chance to practice one algorithm by her own. This contest made her Ph.D. study complete!



Sunday, March 4, 2018

Hackerrank university codesprint

March 4, 2018

Introduction


I still like to learn something from university codesprint 2018. I played university codesprint in 2016 and 2017, but in 2018 I did not have chance to play the contest.

I spent one hour this Saturday to go over the codesprint leader board and then study those top ranking players by country.

Study report


Here is the blog I received from the email about the contest.


Actionable Items


I like to keep the good habit to play Hackerrank contest in 2018. I am planning to play some contest in short future. I like to push myself and challenge myself in the contest, work hard to get some medals.

I have two hobbies, one is to play tennis sports, another one is to play Hackerrank contest.





Friday, May 12, 2017

Maximum Score - Rookie 3 (II)

May 12, 2017

Introduction 


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

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


Code review preparation 



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

May 12, 2017 11:16 pm 

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


Memoization Analysis Challenge


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

Suppose that the array has two numbers, int[] numbers = new int[]{1, 2}. The problem is to find the maximum sum such that the order of two numbers to put into scoring make the value maximum.

What is the subproblem of max score?

Guess what is the subproblem


May 13, 2017 11:03pm

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

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

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

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

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

The memoization process is to record to Dictionary<string, int> calculated.
["0", 1]
["1", 0]
["", 1]


One more test case 


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

Calculated variable as Dictionary<string, int> has the following:
[0 1, 0]
[0 2, 0]
[0, 1]
[1 2, 0]
[1, 0]
[2, 1]
[,1]

Debug the code, and check how many times the dictionary is looked up. 3 times.
key = "0 1", "0 2", "1 2".

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

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


Common advice




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

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

Make it all


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

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

Use bit mask, the code passes all test cases. 
C# practice code is here.


Hackerrank Editorial Notes


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

Here is the link of editorial notes.

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

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


Actionable Items


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

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


Friday, May 6, 2016

HackerRank: Delete duplicate value nodes from a sorted linked list

May 6, 2016

Easy question - Linked List

Problem statement:
https://www.hackerrank.com/challenges/delete-duplicate-value-nodes-from-a-sorted-linked-list

Julia's solution:

https://gist.github.com/jianminchen/9013539e71764a018f3745c514da9d91

Most favorite solution:

https://gist.github.com/jianminchen/a13738b4ab32decb8601f29777172209


/*
  Remove all duplicate elements from a sorted linked list
  Node is defined as
  struct Node
  {
     int data;
     struct Node *next;
  }
*/
Node* RemoveDuplicates(Node *head)
{
    Node *cur = head;
    int last_seen = cur->data;
    while(cur->next) {
        if(cur->next->data == last_seen) {
            cur->next = cur->next->next;
        }else {
            cur = cur->next;
            last_seen = cur->data;
        }
    }
    return head;
}

Question and Answer: 
1. What do you learn through the practice? How long do you take?

Julia spent more than 30 minutes to work on this question; She wrote a two nested loops, and then, came cross time out issue; She tried to direct a pointer to correct position, like 1->1->1->2, she likes to set up first node with value 1's next point to 2. She was in hurry, tried to do it once to make it work in nested second loop. Actually, she figured out the solution just be lazy to let first node with value 1 to point to third node with value 1 first.

Then, she came out this solution using one loop only:

https://gist.github.com/jianminchen/9013539e71764a018f3745c514da9d91

2. What do you learn through studying other submissions?

Julia learned that through the problem solving, she read first 20 submissions, 80% of them should get rid of two loops, or reduce code length to less than 10 lines; one loops is enough to take care of the business; But, people stop when the code works.

Julia knows that value of excellent code. She has to push herself, train herself to discipline herself. 

She found the favorite solution, 
https://gist.github.com/jianminchen/a13738b4ab32decb8601f29777172209

Her new strategy:
Write the code, finish the coding; and then, delete the code, write again. Stop on the best one. And then, try to sort out if there is a bug in the code, test cases etc. And then, discuss or present the code.

Because when the code is short and clean, it shortens time to do code review, bug fixes.

Another concern is that there are so many solutions to solve a problem, only if the solution is short and concise, people can easily follow and tell the correctness.

Statistics and Comment:

1. Read 200 submissions, around 5-10 using recursive function, 80% more than 10 lines of code, over 10 of them use two nested loops.

2. Enjoy the reading; thinking about myself as interviewer, and see how many of them are impressive; I do not see more than 10 of them.

https://www.hackerrank.com/challenges/delete-duplicate-value-nodes-from-a-sorted-linked-list/leaderboard

one more readable code to follow:
https://gist.github.com/jianminchen/b46755065e4d17c82ad793889e2c911b


3. Time spent: reading code submissions - 2+ hours

Look into those:

https://www.hackerrank.com/contests/programming-interviews-practice-session/challenges

https://www.hackerrank.com/contests/algorithms-practice-match-2/challenges

https://www.hackerrank.com/contests/regex-practice-2/challenges

https://www.hackerrank.com/contests/basic-ds-quiz-2/challenges

https://www.hackerrank.com/basic-ds-quiz-2

https://www.hackerrank.com/countercode
https://www.hackerrank.com/accel-contest

Courses to check:
https://www.coursera.org/learn/algorithmic-thinking-1

https://www.coursera.org/learn/algorithmic-thinking-2#

https://www.coursera.org/maestro/api/certificate/get_certificate?verify-code=V5LZ37UU7P


Quizes:
https://www.hackerrank.com/challenges/basic-algo-quiz-1

https://www.hackerrank.com/challenges/data-structures-quiz-2


Find some interesting problems on the link - hackerRank:
https://www.hackerrank.com/roaclark

https://www.hackerrank.com/epiccode

https://www.hackerrank.com/contests/codesprint-practice/challenges

https://www.hackerrank.com/cherry_su

https://www.hackerrank.com/dotgc

Try quick sort in place on HackerRank - 3 questions











Sunday, September 11, 2016

HackerRank contest - stryker codesprint preparation talk

Sept. 11, 2016
It is always a good idea to learn how to prepare very well for a programming contest. Five days away. Let us count down.

Preparation of the coming contest:
Register stryker codesprint  - Sept. 17, 2016

Get prepared, and things to look into:

1. How to prepare for the codesprint?

1. Read the competitive programming book - time analysis, data structure etc.

2. Learn to solve problems using traditional solutions

3. Read some Leetcode solutions - 2+ hours
http://juliachencoding.blogspot.ca/2016/09/a-drill-c-learning.html


4. Read the article - why the company sponseres codesprint?

https://www.hackerrank.com/codesprint5/sponsor
https://www.hackerrank.com/work/customers/rocketfuel
https://www.quora.com/What-is-the-benefit-of-solving-problems-on-HackerRank

Julia only has 4 contests so far/ less than 6 months contest experience vs people over decades of contest experience; be realistic, be pragmatic

Read the article:
https://en.wikipedia.org/wiki/Competitive_programming

Borrow ideas from professional tennis players and teaching pros on contest preparation:

Professional WTA player habits:

1. http://www.humankinetics.com/excerpts/excerpts/learn-the-practice-habits-of-tennis-professionals

Practice to win
Learn to concentrate

Visulization/ margin of error -

2. The 7 Habits of Successful Teaching Pros

http://www.tennisindustrymag.com/articles/2011/01/2_the_7_habits_of_successful_t.html

Blog reading:
1. How to spend the time?
https://www.quora.com/What-are-some-tips-for-programming-interviews-Amazon-Facebook-Microsoft-etc

Julia's note: apply separation of concern, abstraction level -> go to various abstraction level -> various functions, main

concern/ trivial jobs;
main target is to cut time to short, leave time for second question, or things to ask.

5 minutes costs a job - in other words, give different priority for different tasks -
45 minutes interview time / 25 minutes is a threshold - do not push over 25 minutes, leave 20 minutes for something more

meaningful - prepare questions to ask/ figure out if you are best fit/ what is biggest hurdle to overcome

2. 20 minutes reading:
http://www.mohsinali.net/guide.html#prep

3. Leetcode 307: Range sum Query
Spent time to read segment tree - 2.3.3, page 22, 23, 24, competitive programming book.

 So, Julia likes to have some practice on segment tree.

Will come back very soon.

Monday, February 27, 2017

Google's secret to hire the best

Feb. 27, 2017

Introduction

Julia continues her study on Google, read an article: Google's secret to hire the best. Last week, Julia did not dedicate the whole weekend to hackerrank week of code contest, instead, she started to work on the study of Google.

To play a contest on Hackerrank, Julia calculates some math. She has to dedicate herself whole weekend in order to get a medium algorithm done. She has to entertain herself first, play some music, lookup her ideas by Google, write some simple idea to play against hackerrank test case, until she warms up with the algorithm. Sometimes, it takes 5 - 6 hours until she failed so many times and then she understands the problem - what is the real challenge in the problem statement.

All those hours and labor build up her character, she never experience this kind of research before. Over 10 hours, she makes something happen, solve a medium algorithm. Sometimes a medium algorithm can take her a few days. Since Nov. 2016, a few times, she has to continue to catch up more research after the contest, and then work on codereivew.stackexchange.com, get some help and find something more interesting to continue.

Julia learns to work on one algorithm a time, and also has to learn to let it go. She knows that she will forget the algorithm completely, it does not matter how hard she intensively trains herself in the contest/ after the contest, and she needs to relearn it one day. Only thing left is something surprising, her new character still trying to molded, the strong determination to solve the problem. The will, or the intuition to try new ideas, relentlessly. That is something different she could not find in the training of Leetcode algorithms, not time pressure of Hackerrank contest, and no ranking or coding sharing procedures.

Julia likes to read, write and also learn, Google's secret to hire the best. Given a math, 1000 people from phone screen, 4 of them are finally hired. If each 1000 people spend 10 hours time to work on research of Google, that is 4000 hours labor. Julia thinks that it is better to invest time on those 99.6%, share what she studies and help others to move forward on this research.

Study


Read the article - Google's secret to hire the best.

Actionable Item


Google search keyword:
 qdroid 




Sunday, May 14, 2017

Testable JavaScript

May 14, 2017

Introduction


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

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

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

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


Testable JavaScript




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

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

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


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



Book reading 



May 14, 2017 3:20 pm - 4:29 pm
Read the book from page 1 - 13, page 35 / 273, chapter one.

Chapter 2. Complexity 


Code size


Notes:

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

internal and external names of docRoot versus realRoot


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

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

JSLint



Cyclomatic Complexity 



independent paths

jsmeter - a command-line tool


Read the article about Complexity metrics - link is here.

multiple exits -


bad fix probability

Actionable Items



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

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

Read the book "The art of readable code" again. First reading is in 2014, Oct. 31, 2014.
Chapter 8: Break down giant expression - favorite example:

 Two ranges does not overlap

Wednesday, June 28, 2017

Algorithm design talk

June 28, 2017

Introduction


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

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

Binary search algorithm


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

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

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

Mocking experience


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

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


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

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



Wednesday, March 1, 2017

Hackerrank contests - performance review (II)

March 1, 2017


Richness of learning experience


Julia also learned to take those contests seriously, because only if she put all the efforts she can, then she may see some growth over the time. 

First contest she did by her habit, not seeking excellence. And then she noticed that she will have problems to stay that way. 

Week of Code 29               4395/ 9216     Feb. 2017 *
World CodeSprint 9         2164/ 7284     January 2017**
Week of Code 28               2915/ 10421   January 2017***

ACM ICPC Practice Contest 2016   787/ 925            November 2016 ****
Women's CodeSprint 2                     505/ 1882          November 2016 +

University CodeSprint             2081/ 5552     November 2016 ++
WalmartLabs CodeSprint        3226/ 4392     Oct. 2016 +++
World CodeSprint #4               2271/ 5258    June, 2016 ++++
101 Hack Feb 2016                  481/ 723        Feb. 2016  -
Week of Code - 19                    2693/ 3204   Feb. 2016 --


Analysis



Week of Code 29               4395/ 9216     Feb. 2017 *



*( Julia did not work on until last 2 days, and the Sunday she went to church and played tennis, went outdoor from 11:00am - 6:00pm) 



World CodeSprint 9         2164/ 7284     January 2017**



** if Julia started to work on the problem early, same score people had bronze medal. 


Week of Code 28               2915/ 10421   January 2017***



*** very close to top 25%, need to look into the issues 

ACM ICPC Practice Contest 2016   787/ 925            November 2016 ****

**** the algorithms are more difficult to solve, the time is short than other contest.  Julia spent 3 hours in 
the contest.


Women's CodeSprint 2                     505/ 1882          November 2016 +



+ Julia stumbled on a simple recursive algorithm, maximum score 50, she ended up score 0. 
She posted the question on algorithm "stone division" with her C# solution after the contest on codereview.stackexchange.com. 


University CodeSprint             2081/ 5552     November 2016 ++



++ Julia never had chance to work a hard algorithm over 10 hours, so she gambled her luck and 
tried to do some research and problem solving on maximum score 80 - hard algorithm, she ended 
up score 0. 

She learned the lesson of Hackerrank, hackerrank holds high standard on hard algorithm. 


WalmartLabs CodeSprint        3226/ 4392     Oct. 2016 +++



+++ Need to look into the issues, concerns, will come back to add more notes here. 
Julia spent over 10 hours on a 24 hours contest, one hard algorithm called "Interesting Fibonacci Sum", maximum score 100. She tried to submit more than 18 times, but she ended up scored 0 on the algorithm. She did not read medium algorithms problems very carefully, no time to work on. 

After the contest, Julia studied those players good at the hard algorithm, wrote a blog as well. 


World CodeSprint #4               2271/ 5258    June, 2016 ++++



++++ Julia did not know that she can manage to win a bronze medal, at that time, she did not know bronze medal - top 25%. 

She also wrote a lovely blog to document her interest and curiousity. So amazing, like bible verse, Mark 4:8, Still other seed fell on good soil. It came up, grew and produced a crop, some multiplying thirty, some sixty, some a hundred times. 

All she has to do is to give herself time to develop skills, play more contests in the future. She documented her 12 hours labor and score 0 on AorB algorithm. Celebrate the hard work! Post AorB to code review. 

Her blog shares her journey from 40 to 100, won her first bronze medal in her third contests in the row.

More detail see Jianmin Chen hackerrank profile