Created
May 20, 2018 15:05
-
-
Save ThanawatMas/b6b6107786c504b0d3f64a56b4acab87 to your computer and use it in GitHub Desktop.
SolveByCopyToRemove.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SolveByCopyToRemove extends ConcurrentModificationSolution { | |
@Override | |
public void addItemAndReIndex(List<String> roundList, String newItem) { | |
ArrayList<String> copy = new ArrayList<>(); | |
for (String item : roundList) { | |
if (item.equals(newItem)) { | |
copy.add(item); | |
} | |
} | |
roundList.removeAll(copy); | |
roundList.add(0, newItem); | |
} | |
@Override | |
public String solutionName() { | |
return "CopyToRemove"; | |
} | |
public static void main(String[] args) { | |
SolveByCopyToRemove someSense = new SolveByCopyToRemove(); | |
someSense.solve(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment