Python for New Leet Coder - Super Readable Solution
\nclass Solution:\n    def semiOrderedPermutation(self, nums: List[int]) -> int:\n        start, end = 0, len(nums)-1\n        if nums[0] == 1 and nums[-1] == l
```\nclass Solution:\n    def semiOrderedPermutation(self, nums: List[int]) -> int:\n        start, end = 0, len(nums)-1\n        if nums[0] == 1 and nums[-1] == len(nums):\n            return 0\n        \n        for i in range(len(nums)):\n            if nums[i] == 1:\n                start = i\n            if nums[i] == len(nums):\n                end = i\n        \n        if nums[0] == 1:\n            return len(nums) - end - 1\n        \n        if nums[-1] == len(nums):\n            return start\n        \n        if start < end:\n            return (len(nums) - end - 1) + start\n        else:\n            return (len(nums) - end - 1) + start - 1\n```
['Python']