Simple || Clean || Java Solution
\njava []\nclass Solution {\n    public int semiOrderedPermutation(int[] nums) {\n        int opr = 0, j = 0;\n//         finding 1\n        for(int i=0; i<nums
\n```java []\nclass Solution {\n    public int semiOrderedPermutation(int[] nums) {\n        int opr = 0, j = 0;\n//         finding 1\n        for(int i=0; i<nums.length; i++)    \n            if(nums[i] == 1)    j = i;\n//         operating 1 to start index\n        while(j > 0){\n            nums[j] = nums[j-1];\n            nums[j-1] = 1;\n            opr++;\n            j--;\n        }\n//         finding n\n        for(int i=0; i<nums.length; i++)    \n            if(nums[i] == nums.length)    j = i;\n//         operating n to last index\n        while(j < nums.length-1){\n            nums[j] = nums[j+1];\n            nums[j+1] = nums.length;\n            opr++;\n            j++;\n        }   \n        return opr;\n    }\n}\n```
['Java']