why is O(n)? I think remove() method in ArrayList is O(n). And overall time complexity will be O(n2)
O(2*n) is O(n) by definition...
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.