You are viewing a single comment's thread. Return to all comments →
java8
public static int runningTime(List<Integer> arr) { int shiftCounter = 0; for (int i=1; i < arr.size(); i++) { for (int j=0; j < i; j++) { if (arr.get(i) < arr.get(j)) { int toInsert = arr.remove(i); arr.add(j, toInsert); shiftCounter += i-j; } } } return shiftCounter; }
Seems like cookies are disabled on this browser, please enable them to open this website
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
java8