Hash map from scratch · Compiler
Hash map from scratch
Implement an initially empty stock map with 26 buckets, one per first letter of a plant name. Keep a list of full name and stock pairs in each bucket. PUT name value replaces the stock for that exact name or adds a pair if absent. GET name looks up that exact name.
- Input
- The first line contains q (1 <= q <= 100). The next q lines each contain PUT name value or GET name. Names have 1 to 20 lowercase ASCII letters. Values are integers from 0 to 10000. At least one command is GET.
- Output
- For each GET in order, print the stored stock on its own line, or MISSING if the name has no entry.
Compiler Explorer runs your code when you run or check it.
Loading your exercise draft…