C++ could we grind 1 swap?
\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int first = -1;\n        int last = -1;\n        for(int i = 0;i<nums.
```\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int first = -1;\n        int last = -1;\n        for(int i = 0;i<nums.size();++i)\n        {\n            if(nums[i]==1)\n                first = i;\n            if(nums[i] == nums.size())\n                last = i;\n        }\n        return first>last?first+nums.size()-1-last-1:first+nums.size()-1-last;\n    }\n};\n```
['C++']