Google Coding Interview Question | Leetcode 1509 | Min Diff Between Max and Min Value in Three Moves

Поділитися
Вставка
  • Опубліковано 31 січ 2025

КОМЕНТАРІ • 6

  • @yitingg7942
    @yitingg7942 3 роки тому +6

    Thanks I feel this question is easy to code but hard to think of.

  • @jkim5118
    @jkim5118 3 роки тому +1

    Why is the optimal solution O(N)? Storing 4 mins/maxes into the PQ would take O(NlogN). Wouldn't it?

    • @EshwarNorthEast
      @EshwarNorthEast 3 роки тому +1

      At a time you would have only 4 values in the heap. I supposes its N log 4 which is N since log 4 is a constant.
      Hope it is clear.

  • @aw6507
    @aw6507 3 роки тому +1

    this doesn't seem to work if there are duplicate?

  • @jay-rathod-01
    @jay-rathod-01 3 роки тому

    It was fun