How to count the number of times sorted array with distinct integers are circularly rotated in Python

1 Answer

0 votes
def countRotations(arr) :
    size = len(arr)
    min = arr[0] 
    min_index = 0
    
    for i in range(0, size): 
        if (min > arr[i]): 
            min = arr[i] 
            min_index = i 
          
    return min_index; 
    
arr = [23, 19, 15, 4, 6, 8, 9, 11]

print(countRotations(arr))



'''
run:

3

'''

 



answered Nov 21, 2023 by avibootz
...