β back to unit
Easy
# searching easy
The Heaviest Dragon Egg
Dragon eggs are hatching soon, and the heaviest one always hatches first! π₯π
You get a list of egg weights (at least one egg). Find the biggest weight and save it in best β no max() shortcut, track it yourself.
Example:
Input: weights = [31, 45, 29, 45, 12]
Output: 45
Starting with best = 31, each weight challenges it β 45 beats 31 and becomes the new best. Nothing later beats 45, so that's the final answer.
π‘ need a hint?
srch-heaviest-egg.pyπ given lines are locked β write your code in between
loading...