Print the number of such shifting required to sort the array. There can be multiple possibilities.
Input: arr[] = [1, 3, 2, 8, 5]
Output: 2
Explanation: Consider segment from index = 1 to index = 2. [1, 3, 2, 8, 5]. Now rotate this segment by 1 offset. The new array becomes, [1, 2, 3, 8, 5].
Then consider segment from index = 3 to index = 4, [1, 2, 3, 8, 5]. Rotate it by 1 offset, the new array becomes, [1, 2, 3, 5, 8].
Input: arr[] = [2, 4, 1, 3]
Output: 2
Explanation: From index = 0 to index = 2, [2, 4, 1, 3]. Rotate this segment by 2 offset on left, the new array becomes, [1, 2, 4, 3].
Taking second segment from index = 2 to index = 3 of offset 1, rotate it the new array becomes, [1, 2, 4, 3].