Loading...
Loading...
Loading...
A store keeps its open order numbers in a list. A customer cancels one order: remove that order number from the list. Take care: on a List<Integer>, remove(5) removes the item at index 5, not the number 5.
Cancelled <number>; otherwise Not found. Then Open: <list> with the list printed as [a, b, c].Example 1
Input
4 101 102 103 104 103
Output
Cancelled 103 Open: [101, 102, 104]
Example 2
Input
3 1 2 3 1
Output
Cancelled 1 Open: [2, 3]
The number 1 is removed, not the item at index 1.
Try the problem first. Open one hint at a time.
remove(Integer.valueOf(number)) removes the first item equal to the number and returns true or false.
Use the returned boolean to choose between Cancelled and Not found.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor