Time Complexity of ArrayList Removal
What is the time complexity of the removeElements method shown below, where n is the number of elements initially in list?
public void removeElements(java.util.ArrayList<Integer> list) {
while (!list.isEmpty()) {
list.remove(0);
}
}
A
O(log n)
B
O(n^2)
C
O(n)
D
O(1)
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | thuyjerry | 0 | 1 | 0m 00s | -10 |
| #2 | turan.musayev.28072020 | 0 | 1 | 0m 58s | -68 |
| #3 | zgj07310417 | 0 | 3 | 1m 11s | -101 |
| #4 | lsj08030922 | 3 | 5 | 9m 22s | -282 |
Items per page:
10
1 – 4 of 4
APFIVE