semi order permutation
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->o(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->o(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int n=nums.size();\n        int count=0;\n        int i=0;\n        while(i<n){\n            if(nums[0]==1){\n                break;\n            }\n            if(nums[i]==1&&i!=0){\n                swap(nums[i],nums[i-1]);\n                count++;\n                i--;\n            }\n            else i++;\n        }\n        int value=0;\n        for(int i=0;i<n;i++){\n            if(nums[i]==n)value=i;\n        }\n        return count+n-value-1;\n    }\n};\n```
['C++']