Approach

We check the condition from the end and return the number that first breaking the ordering.

Code

class Solution {
public:
    int minimumPrefixLength(vector<int>& nums) {
        int n = nums.size();
        int minIdx = n-1;
        for(int i = n-2 ; i >= 0 ; --i) {
            if(nums[i] >= nums[i+1]) break;
            minIdx = i;
        }
        return minIdx;
    }
};