Skip to content

hxtomprice/unicorn-ninja-coding-challenge-2019-08-23

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commitizen friendly

🦄 Unicorn Ninja Coding Challenge for 2019-08-23

(Adapted from: Daily Coding Challenge @ 2019-08-18.)

You are given an array representing the heights of neighboring buildings on a city street, from east to west. The city assessor would like you to write an algorithm that returns how many of these buildings have a view of the setting sun, in order to properly value the street.

For example, given the array [3, 7, 8, 3, 6, 1], you should return 3, since the top floors of the buildings with heights 8, 6, and 1 all have an unobstructed view to the west.

For bonus 🦄 points, can you solve this problem using just one forward pass through the array?

⚠️ Note that you should only use the standard library of your language of choice (no external packages allowed).

If you choose to implement your solution using Node.js, this challenge comes with a unit test suite, which can be used to verify the correctness of your solution, which can be run with npm test or yarn test. The unit tests expect your module named challenge.js to export a unobstructedWestViewCount function that takes an array of integers as its arguments and returns an integer.

Rules of engagement

Fork this repository and be ready to submit a PR with your solution when the time limit for the challenge is reached.

About

Unicorn Ninja Coding Challenge for 2019-08-23

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%