Loading...
Loading...
Loading...
Two stores list the products they sell, and a product can be listed more than once. Find the products that both stores sell.
Example
Input
4 laptop mouse cable mouse 3 cable keyboard laptop
Output
2 cable laptop
cable and laptop are in both lists.
Try the problem first. Open one hint at a time.
Copy store A into a TreeSet, then call retainAll with store B.
Print size(), then loop over the result.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor