GET INDEX OF 1 & n || C++
get index 1 and n\na = index of 1;\nb = index of n\nif(index of 1 < index of n)\n    than return a+n-1-b;\nelse return a+n-1-b-n//there is we substracte previou
get index 1 and n\na = index of 1;\nb = index of n\nif(index of 1 < index of n)\n    than return a+n-1-b;\nelse return a+n-1-b-n//there is we substracte previous ans by 1 because here one case is possible that we swap(1,n)\n# Code\n```\nclass Solution {\npublic:\n    int semiOrderedPermutation(vector<int>& nums) {\n        int a,b,i,n=nums.size();\n        for(i = 0; i < n; i++){\n            if(nums[i]==1)a = i;\n            else if(nums[i]==n)b = i;\n        }\n        if(a<b){\n            return a+n-1-b;\n        }else{\n            return a+n-1-b-1;\n        }\n    }\n};\n```
['C++']