C++ || easy solution
Intuition\n Describe your first thoughts on how to solve this problem. \nFind the position of 1 and the n in the nums which will take o(n)\ni have used find but
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFind the position of 1 and the n in the nums which will take o(n)\ni have used find but simple iteration can also be done to find the pos of both the elements \n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Find the pos of both the element using simple iteration or find \n2. Their are only two case which we have to see now \n             i.pos_1 < pos_2\n             ii. pos_1 > pos_2\n3. For case i we simple add the no of swaps need for both the element to reach their respective position \n4. for case ii we do the same as for case i but subtract 1 from it as when we were swaping elements for 1 as the pos_2 < pos_1 then the n element must have shifted by one toward its destination so -1 to the ans\n# Complexity\n- Time complexity:\n\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n      O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n      O(1)\n# Code\n```\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int n = nums.size();\n        int pos_1 = find(nums.begin(),nums.end(),1) - nums.begin();\n        int pos_2 = find(nums.begin(),nums.end(),n) - nums.begin();\n        return (pos_1<pos_2) ?(pos_1 +  n-1-pos_2):(pos_1 + (n-1 - pos_2) - (1));\n\n\n    }\n};\n```
['C++']