Another Big O question, yet I can't wrap my head around it:
for (int i = 0; i < n; i++)
    for (int j = 0; j < n * n; j++)
        for (int k = 0; k < j; k++)
            //do sth
My thought: The outer loop is O(n). The middle is O(n^2). However, the inner depends on the middle, so for each j, k is gonna run 1+2+3+...+n = [n^2(n^2+1)]/2 which is the same as O(n^4).
So instead the middle runs about O(n^2), it actually runs O(n^4). Which would result in O(n^5). Is that correct?
 
    
