Imagine a scenario where the second loop is iterated once for each iteration of n except the last one where it is iterated m times:
// n and m are two different variables.
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
if(i!=(n-1)) break;
// O(1) code here.
}
}
What would be the time complexity of this? Is it O(n*m), O(n+m) or something else?