LinkedList<Integer> lst = ...; int sum = 0; for (Integer i : lst ) sum += i;
What is the Big O of this code?
Answer: B
Using the for-each loop with the : is convenient, involves less code, and has a good Big O for both LinkedList and ArrayList.
Contents Page-10 Prev Next Page+10 Index