Блог пользователя akshat11

Автор akshat11, история, 2 года назад, По-английски

Problem link — https://leetcode.com/problems/furthest-building-you-can-reach/

I am able to come up with the solution after some time but I still don't know and am not able to debug why my previous solution giving wrong answer for particular test case.Could anyone help me to figure it out?

code:

https://leetcode.com/submissions/detail/727643769/

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You can do this using binary search.

https://leetcode.com/submissions/detail/727789686/

Indentation might be a bit messed up, I wrote this on my phone.

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Consider the case:

heights = [1, 5, 6, 7] bricks = 2 ladders = 0

Your code returns 2. But with only two bricks you cant even move a single building. So the correct answer would be 0.