Ad
  • Default User Avatar

    Note that you can start at first or second step. Likewise you can end at last or second to last step. In the order given in the description:

    climbing_stairs([0, 2, 2, 1]) ➞ 2

    The cheapest route is the first (index-0) and third step (index-2). So 0 + 2 = 2.

    An alternative route is the second (index-1) and third step (index-2). So 2 + 2 = 4, but that is more expensive than the first route.

    Another alternative route is the second (index-1) and fourth step (index-3). So 2 + 1 = 3, but that is also more expensive than the first route.

    climbing_stairs([0, 2, 3, 2]) ➞ 3

    The cheapest route is the first (index-0) and third step (index-2). So 0 + 3 = 3.

    climbing_stairs([10, 15, 20]) ➞ 15

    The cheapest route is the second step (index-1). So the cost is just 15.

    climbing_stairs([0, 0, 0, 0, 0, 0]) ➞ 0

    Here the cheapest route is any legal route as all "jumps" are free.

  • Default User Avatar

    Read my reply below to the exact same comment.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    1st question: No ridesharing, each pickup and dropoff pair needs 1 taxi.
    2nd question: A single batch of requests, the pickup and dropoff times indicate when the taxi should actually be in operation.

  • Default User Avatar

    Fixed, thanks.

  • Default User Avatar

    If anyone wants to translate the kata to other languages, I'd be more than happy to approve it.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    O(n^2) will not pass, you need to make it more efficient.

    It's hard to balance giving you advice and spelling out the solution. But, I will try nonetheless.

    • Would sorting the requests help?
    • Look at the tags, if are you unfamiliar with any of the tags, google it.
    • You need to proccess all requests, this has to be O(n).
    • For each request, what are the options? Either you have a taxi that is idle that you can send on a new mission or you need a new taxi. Can you figure out a way to store all the existing taxis and retrieve one or more that are available? Does this have to be O(n)?
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Ok, I just did. Thanks again.

  • Default User Avatar

    They are not. Thank you for looking at my kata and giving me feedback.

  • Default User Avatar

    You can longer do this as far as I can see.

  • Default User Avatar

    This has been fixed, your cheating solution no longer works.

  • Loading more items...