Skip to content

Instantly share code, notes, and snippets.

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

  • Save PythonCoderAS/8faf0ca26797e0419fc0115a7d63cffc to your computer and use it in GitHub Desktop.

Select an option

Save PythonCoderAS/8faf0ca26797e0419fc0115a7d63cffc 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