Math, asked by jungkookie15, 4 months ago

given a string A which contains only three characters {'X','o','.'}. Find minimum possible distance between any pastor of 'x' and 'o' on the string. Distance is defined as the absolute difference between the indeed of 'x' and 'o' . Note: If there is no such pair return-1​

Answers

Answered by sureshbhajantri318
5

Answer:

No answer ................

Answered by adsalunke090
0

Answer:

int solve(char *A){

int min=-1,i=0,size;

size=sizeOf(A)/sizeOf(A[0]);

while(i<size){

if(A[i]=='x' || A[i]=='o'){

int temp=Find_Diff(i,A);

if(min==-1)

min=temp;

else if(min>temp)

      min=temp;

}

i++;

}

return min;

}

int Find_Diff(int i,char* A){

int j=i+1;

while( j< (sizeOf(A)/sizeOf(A[0] ) ) ) {

if(A[j] !=' . ' && A[j] !=A[i])

return j-i;

}

return -1;

}

Step-by-step explanation:

Similar questions