Loading...
Loading...
Loading...
A store keeps the products of a category in a list, and a product name can appear more than once. Some product names are out of stock. Remove every product whose name is out of stock and print what is left.
Left: <count>, then the remaining names in the original order on one line separated by spaces, or the word none when nothing is left.Example
Input
6 Pen Bag Pen Mug Cap Bag 2 Pen Cap
Output
Left: 3 Bag Mug Bag
Both copies of Pen and the Cap are removed.
Try the problem first. Open one hint at a time.
Keep the out-of-stock names in a second list so you can ask gone.contains(name).
Do not remove inside a for-each loop. removeIf with a lambda removes every match in one call.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor