simple logic!!
\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int n = nums.size();\n        int i = 0, j = 0;\n        for (int x = 
```\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int n = nums.size();\n        int i = 0, j = 0;\n        for (int x = 0; x<n; x++) {\n            if (nums[x] == 1) i = x;\n            if (nums[x] == n) j = x;\n        }\n\n        if (j < i) return i + n-j-2;\n        return i + n-j-1;\n    }\n};\n```
['C++']