← back to unit
Medium
# searching medium
Heaviest and Lightest at Once
The moving crew wants both extremes: the heaviest box goes on the bottom, the lightest on top. 📦
You get a list of box weights (at least one). In ONE pass, find both. Print the heaviest, then a space, then the lightest.
Example:
Input: weights = [14, 3, 27, 8]
Output: 27 3
Tracking both extremes in one pass, the heaviest box is 27 and the lightest is 3.
💡 need a hint?
srch-heaviest-lightest.py🔒 given lines are locked — write your code in between
loading...