[HackerRank] Apple and Orange

Apple and Orange

This was the first HackerRank problem that I had to refactor specifically for performance. It kept timing out on the submission. I wish now I had committed earlier versions just so it would be easier to see the changes as I went through them.

Initially I had a list of every value between the house start and finish, and would compare every apple & orange fall coordinate value to see if it was in that list. That turned out to be very very slow, so I eventually got it to work by just checking if it fell within a range. In retrospect it’s pretty obvious.

HackerRank Link: http://ift.tt/2kiqLOc

February 11, 2017 at 02:42PM
via GitHub http://ift.tt/2l1zBEH

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s