In Java, if the answer is wrong, I will dislike.
Define a static method named removeExtremes(ArrayList<Integer> numbers) that takes an ArrayList of integers as a parameter. The method processes the ArrayList elements backwards and removes the elements that are less than -1000 or greater than 1000.
Note: The ArrayList is changed in place (i.e. the method updates the parameter ArrayList and does not return a new ArrayList). You can assume that the ArrayList is not empty.
For example:
Test:
Result:
ArrayList<Integer> arrayList = new ArrayList<Integer>();
Collections.addAll(arrayList, 476, -1000, 1656, -1000, 1308, 774, -1175, 1195, 1602, -2800);
removeExtremes(arrayList);
System.out.println(arrayList);
Answer: penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %