HashMap: Exercise Solution

Problem 1: Find the highest stock price

Find the company with the highest stock price.

Solution:

To find the company with the highest stock price, we will have to first iterate the HashMap. We can get the EntrySet and then iterate over it. For each entry, we will check if the stock price is more than whatever max value we have. If yes, we will store the company corresponding to this entry in a variable.

Get hands-on with 1200+ tech skills courses.