fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int getNumberRotation(int arr[],int n){
  5. for(int i=1;i<n;i++)
  6. if(arr[i]<arr[i-1])
  7. return i;
  8.  
  9. return -1;
  10. }
  11.  
  12. int main() {
  13. int arr[]={15,18,2,3,6,12};
  14. int n=sizeof(arr)/sizeof(int);
  15. cout<<"Size of array: "<<n<<"\n";
  16. cout<<"Get Number of Rotations -brute: "<<getNumberRotation(arr,n)<<"\n";
  17. return 0;
  18. }
Success #stdin #stdout 0s 5584KB
stdin
Standard input is empty
stdout
Size of array: 6
Get Number of Rotations -brute: 2