Hackerrank – HourRank5 – Hr City

nice problem, have to be extra careful when writing the recurrence relations.

dist[n] denotes the sum of the distances between each pair of nodes in the nth step.

coun[n] denotes the number of nodes in the nth step.

cdis[n] denotes the distance from every node to the corner of the structure in the nth step

corn[n] denotes the distance between north east corner to south west corner of the structure in the step

https://gist.github.com/6687e9341af3f0aaf216

Advertisements