for (int i = 0; i < this.tiles.length * this.tiles.length; i++) {
int row = i / this.tiles.length;
int col = i % this.tiles.length;
for (int j = i+1; j < this.tiles.length * this.tiles.length; j++) {
int compareRow = j / this.tiles.length;
int compareCol = j % this.tiles.length;
if(this.tiles[compareRow][compareCol] < this.tiles[row][col]) {
count++;
}
}
}
我必须计算这个函数的时间复杂度,我首先认为它是 ~n*n-1 但我很确定这实际上是错误的。谁能解释这段代码的时间复杂度是多少?