This problem feels like checking a list of test scores after an exam. You want to know which score was the highest in the group.
The answer is simply the largest number in the list. You do not need to sort the whole list. You only need to keep track of the best score seen so far.
For example, if the scores are [72, 88, 91, 84], the answer is 91. That is the highest value in the whole list.
If the list is empty, return -1 because there is no score to report.
Example Input & Output
91 is the highest score in the list.
With one score, that value is automatically the highest.
An empty list has no valid score to return.
Algorithm Flow

Solution Approach
A good way to solve this is to keep a variable for the highest score found so far.
First, handle the empty-list case. If there are no scores, return -1.
If the list has values, store the first score in a variable like highest. That gives you a starting answer.
Then go through the rest of the scores and compare each one with highest.
The update rule is:
Whenever you find a larger score, replace the old value. If not, keep the value you already have.
At the end, highest is the best score in the list.
Best Answers
Solutions Coming Soon
Verified best solutions for this Challenge are still being analyzed and will be available soon.
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
