Showing posts with label week code 27. Show all posts
Showing posts with label week code 27. Show all posts

Wednesday, December 28, 2016

HackerRank week code 27 - Hackonacci Matrix Rotations

Dec. 28, 2016

Problem statement

Score 4 - Maximum score: 40

Julia C# practice

Julia had great time to practice matrix rotations, she spent over 2+ hours to work on rotation details.

Timeout is a biggest issue. Most of top players got tip from HackerRank email to use matrix manipulation called ?.

Read editorial notes, please.

Time spent in the contest:

2+ hours

Study Google employee's code

So simple, it will take less than 20 minutes to write and read:
C++

C++

Study facebook employee code:

1. Code looks like Julia's, so Julia will study more on this implementation: Rank 40 (7000+ players)

https://www.hackerrank.com/maxvv

Java 8

Study Amazon employee's code:

Java

Important!! Study the above code, Julia, you do not need to rotate the matrix, just compare each pair of numbers:
Java Code to study

line 24 - 36.

Stanford university:

Java 7


Lesson learned:

Hackerrank sent out an email for the tip - use matrix exponentiation, top players used the tips and also if Julia checked the discussion session, top 500 players were discussing the matrix exponentiation as well. 

Julia has to pay attention to detail, go through the discussions and involve discussion as well. 

From score 4 to 40, it takes some research, and change the design of algorithm accordingly.

Follow up after 3 months


March 8, 2017
1. Read blogs written by a facebook scientist:
blogs about algorithms

   Study one scientist a time, figure out what I can learn from his experience. Ginseppe M. Mazzeo

2. Understand the algorithm, post is on code review.

HackerRank - week code 27 - Bronze medal III

Dec. 28, 2016

Introduction
As a hackerrank player, Julia has over 8 months experience. She just likes to be a weekend hackerank player. But she could not find anything in late December, she was busy with holiday parties and missed one contest in December.

But at the end of December, she studied the code written by over 20,000 players, and found one of players played a lot of week code contests.

So, Julia played the week code 27, and she had good time to play and learn something new.

Workout

Facts:
Worked on 5 algorithms -
first one, tailor shop, hackonacci matrix rotation, zero-move nim, last one: how many substrings

Her most favorite algorithm, it is an easy algorithm. But it is fun and a lot of challenging for her. Time complexity is the biggest concern.

Tailor shop


And then, she worked hard on the algorithm, she just enjoyed and then was happy that recursive function does some work for her; and took 1 or 2 hours to study game - Nim, and had a good time to study some game, mathematics.

Hackonacci matrix rotation

score 4 - maximum score 40

Preprocessing, and time complexity is the biggest issue


Zero-Move Nim

Her practice on recursive solution (2+ hours), score 5 - maximum score 50
A lot of fun to practice - learn recursive function
https://gist.github.com/jianminchen/6c0dea2e0f6d500543db06ff640005a9

Using nim sum:

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

Study code submitted by Google employees:

Java code:

C++ 14 code

C++ 14




How many substrings




Tip to share:
Read discussion on HackerRank, and find out top players - what they are discussing, tips they share in the contest or after the contest.