fire
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
This should work. how to compute the time complexity ?
void sortRelative(int[] m){
int insertNegative = 0;
for (int index = 0; index < m.length; index++){
if (m[index] < 0 && m[insertNegative] >= 0){
int temp = m[index];
for (int k = index; k > insertNegative; k--){
m[k] = m[k-1];
}
m[insertNegative++] = temp;
} else {
if (m[insertNegative] < 0){
insertNegative++;
}
}
}
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Please tell me what's its time and space complexity:
- fire August 24, 2013