Sunday, February 21, 2016

HackerRank - New School - Algorithm: Fix the cycles

Feb. 21, 2016

Another 2 hours on hackerRank:

Fix the cycles:
Problem Statement:
https://github.com/jianminchen/HackRank/blob/master/fixTheCycles/fix-the-cycles-English.jpg

Solution:
There are 4 cycles which share same edge: D->A, so if set D->A big enough then any cycle can be positive.

4 cycles:
A B C D  A
A C D A
A B D A
A C D A

Simple solution.
30 minutes to read - take too long!
10 minutes to write code,

https://github.com/jianminchen/HackRank/blob/master/fixTheCycles/FixCycles.cs

Short term target of training on hackerRank:
Easy question,
reading time: 10 minutes,
code time: 10 minutes.
Know how to fix bugs, make more points



No comments:

Post a Comment