β back to unit
Medium
# searching medium
Find the Last Empty Locker
New kid at school gets their pick of the empty lockers β and wants the one farthest down the hall. π
You get a list where each locker is empty or full. Print the position (from 0) of the LAST empty locker, or none if the hall is packed.
Example:
Input: lockers = ["full", "empty", "full", "empty", "full"]
Output: 3
Empty lockers sit at positions 1 and 3. Overwriting the saved position every time you pass one leaves 3 β the last one.
π‘ need a hint?
srch-last-empty-locker.pyπ given lines are locked β write your code in between
loading...