Given a array, find the min K which means the count of number to delete that will make the last number
as the min number.
#include<stdlib.h>
int findMinK(int* array, int len){
int i = len-1;
int j;
int k =len;
int tempK =0;
int temp = 0;
for(; i >= 0; i--){
temp = array[i];
tempK = len-1 -i;
for(j = 0; j < i; j++){
if(array[j] < temp){
tempK++;
}
}
if(k > tempK){
k = tempK;
}
}
return k;
}
int main(){
int array[] = {3,2,5,6,7};
int result = findMinK(array, 5);
printf("The min K is: %d",result);
getchar();
}
as the min number.