Loading...
Loading...
Loading...
An online store lists its products with the quantity in stock. A product may be listed twice; the later quantity is the current one. Answer a list of queries: print the quantity of a product, or NOT FOUND if the store does not list it.
<product> <quantity>. Then a line with q, and q lines with one product name each.NOT FOUND, one per line.Example
Input
3 Pen 25 Marker 12 Notebook 8 3 Marker Cable Pen
Output
12 NOT FOUND 25
Cable is not listed.
Try the problem first. Open one hint at a time.
Put every line in a HashMap<String, Integer>; a second put replaces the first.
Use containsKey, not get(...) == 0, to tell a quantity of 0 from a missing product.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor