Big O complexity

What is the time complexity of this:

while(L1.contains(obj)) {
if (L2.size() > L1.size()){
L2.remove(L2.size() - 1);

Is it O(n) because it might take as many as n times for the while statement to evaluate as false?
Depends on the data structure of L1 and L2.

If their remove(0) (or remove(lastobject)) takes O(n) as well, then the whole thing can be O(n2).
Last edited on
Topic archived. No new replies allowed.