We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I just ran a small test to check if the Map[cost] to FlavorIdx approach has a bug in it. It does. This is why Gayle's YouTube video uses BinarySearch on Cost entries ordered by FlavorIdx.
In this test sequence; the Flavor at position 2 overwrites/loses the flavor at position 1.
What's interesting though; is that this test case appears to be missing from the Hacker Rank test suite; because this Map[cost] code approach was passing all of their test suite.
Here's my Python code (formatted on next comment):
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
@Dan_Golding
I just ran a small test to check if the Map[cost] to FlavorIdx approach has a bug in it. It does. This is why Gayle's YouTube video uses BinarySearch on Cost entries ordered by FlavorIdx.
In this test sequence; the Flavor at position 2 overwrites/loses the flavor at position 1.
What's interesting though; is that this test case appears to be missing from the Hacker Rank test suite; because this Map[cost] code approach was passing all of their test suite.
Here's my Python code (formatted on next comment):