Skip to content

Instantly share code, notes, and snippets.

@cyan-at
Created February 28, 2015 06:08
Show Gist options
  • Save cyan-at/c80cbadf0c1c7325b695 to your computer and use it in GitHub Desktop.
Save cyan-at/c80cbadf0c1c7325b695 to your computer and use it in GitHub Desktop.
public void stutter(ArrayList<String> list) {
int l = list.size();
// seed
for (int i = 0; i < l; i++){
list.add("");
}
// work backwards
int f = list.size() - 1;
for (int i = l - 1; i >= 0; i--){
String temp = list.get(i);
list.set(f, temp);
list.set(f-1, temp);
f = f - 2;
}
// f should be 0
// i should be 0
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment