Boats to Save People - Leetcode 881 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ม.ค. 2025

ความคิดเห็น • 8

  • @techerror8
    @techerror8  ปีที่แล้ว +1

    Like 👍
    Share 📣
    Comment 💬
    Click this link to Subscribe 👉tinyurl.com/4e2nj4vr
    Press the Bell icon🔔for updates

  • @prog2597
    @prog2597 ปีที่แล้ว +1

    Nice Explanation

    • @techerror8
      @techerror8  ปีที่แล้ว +1

      Glad it Helped :)

  • @vanidevim4773
    @vanidevim4773 ปีที่แล้ว +1

    good job, keep doing it

    • @techerror8
      @techerror8  ปีที่แล้ว +2

      Glad it Helped :) Thank You :)

  • @BirdyNamNaam
    @BirdyNamNaam ปีที่แล้ว +1

    what if people = [1,2,3,4,5] and limit is only 3

    • @techerror8
      @techerror8  ปีที่แล้ว +1

      for the input people = [1,2,3,4,5] and limit = 3, it would return 4, indicating that a minimum of 4 boats are needed to rescue all the people. The method sorts the people list in ascending order and uses two pointers to iterate through the list, assigning each pair of the lightest and heaviest people to a boat if their total weight is less than or equal to the limit. Hope this Helps :) Subscribe for more :)

    • @BirdyNamNaam
      @BirdyNamNaam ปีที่แล้ว

      @@techerror8 if we pair 1 and 5 and add them it would be 6 which is > 3 so we will send 5 alone in the boat but limit is 3 and 5 > 3 so how will it go in a boat, this keeps hunting me 🥲