Homework: Looking for better strategy, or approach rather than complete code.
I\'v got two arrayLists of integers under two conditions:
I propose the following code:
private static List joinTwoLists(List a, List b) {
final boolean aIsBigger = a.size() > b.size();
final List joined = new ArrayList<>(aIsBigger ? a : b);
final AtomicInteger index = new AtomicInteger(1);
for (Integer value : aIsBigger ? b : a) {
joined.add(index.getAndAdd(2), value);
}
return joined;
}