Pick Cheapest Lunch
This problem comes from a simple lunch decision. You have a list of menu prices, and you want to choose the cheapest option.
The task is not to sort the whole menu or remember every possible order. You only need to find the smallest price in the list.
For example, if the prices are [25, 18, 22, 30], the answer is 18. That is the lowest price among all the lunch options.
If the list is empty, return -1 because there is no lunch option to choose from.
Example Input & Output
No menu options means there is no valid cheapest price.
18 is the cheapest menu price in the list.
With only one lunch option, that price is the answer.
Algorithm Flow

Solution Approach
A good method for this problem is almost the same as finding the largest value, except now you are looking for the smallest one.
First, handle the empty-list case. If there are no menu prices, return -1.
If the list has values, store the first price in a variable like cheapest. That gives you a starting answer.
Then move through the rest of the list and compare each price with cheapest.
The update rule is:
Whenever you find a smaller value, replace the old one. If not, keep what you already have.
At the end of the loop, cheapest is the lowest lunch price in the list, so that is the answer you print.
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.
