Skip to content

Instantly share code, notes, and snippets.

@PythonCoderAS
Created May 22, 2022 00:19
Show Gist options
  • Select an option

  • Save PythonCoderAS/864c1ea8c81fb27e5bf5d95e251ec546 to your computer and use it in GitHub Desktop.

Select an option

Save PythonCoderAS/864c1ea8c81fb27e5bf5d95e251ec546 to your computer and use it in GitHub Desktop.
public void interleave(ArrayList<Integer> a1, ArrayList<Integer> a2){
Iterator<Integer> it2 = a2.iterator();
int idx = 0;
while (it2.hasNext()){
idx++;
if (idx < a1.size()){
a1.add(idx, it2.next());
} else {
a1.add(it2.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment