I came across this question for the Big O time complexity of this code snippet: It is guaranteed that the time complexity for the following code is O(n^4).
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = n; i>=1; i--) //n
for(int j = 1; j<=i; j++) //n
if(!list.contains(i*j)) //n?
list.add(i*j); //1?
My Question: Why is it O(n^4) instead of O(n^3)?