Home > Back-end >  Leetcode servers running results are different, and I want to ask is where there is a problem?
Leetcode servers running results are different, and I want to ask is where there is a problem?

Time:11-13

Leetcode 1051. Height checker, the topic is an array of easy,
But is
In this test case,1,4,2,1,3 [1]
Eclipse leetcode as well run on the playground run is above 5, expectations are the is 5,
But leetcode server is 3... Really don't know why

With bubble sort,
The class Solution {
Public int heightChecker (int [] h) {

Int I, j, temp, exchange, count=0;
for(i=0; iExchange=0;
For (j=h.l ength - 1; j> i; J -) {
If (h [j] Temp=h [j];
H=h [j] [1];
H [1]=temp;
Exchange=1;
}
}
count++;
If (exchange==0) break;//exchange didn't happen, no longer ordering
}

count++;
Return the count.
}
}

O great god see... _ _ (: з) <)
  • Related