Easy Solution || C++
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:O(n)\n\n- Space complexity:O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int mini=0;\n        int maxi=0;\n        int n=nums.size();\n        for(int i=0 ; i < n ; i++){\n            if(nums[i]==1){\n                mini=i;\n            }\n            else if(nums[i]==n){\n                maxi=i;\n            }\n        }\n        if(mini>maxi){\n            maxi=(n-1)-(maxi+1);\n        }\n        else{\n            maxi=(n-1)-maxi;\n        }\n        return mini+maxi;\n    }\n};\n```
['C++']