Since you have two nested loops, you have run-time complexity O(m*n). This is because, for n- Personin deepCopyPersonSetyou repeat magain. nin this example, this is the number Personin personList.
Your code is basically:
for(int i = 0, i < m, i++)
for(int j = 0, j < n, j++)
For each iteration m, we have n code iterations
source
share