solution for 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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```csharp []\npublic class Solution {\n    public int SemiOrderedPermutation(int[] nums) {\n        int times = 0;\n        while(!(nums[0] == 1 && nums[nums.Length - 1] == nums.Length)){\n            for (int i = 0; i < nums.Length; i++){\n                if (nums[i] == 1 && i > 0) {\n                    for (int j = i; j >= 1; j--){\n                        int temp = nums[j];\n                        nums[j] = nums[j-1];\n                        nums[j-1] = temp;\n                        times++;\n                    }\n                }\n                else if(nums[i] == nums.Length && i < nums.Length-1){\n                    for (int j = i; j < nums.Length-1; j++){\n                        int temp = nums[j];\n                        nums[j] = nums[j+1];\n                        nums[j+1] = temp;\n                        times++;\n                    }\n                    i--;\n                }\n            }\n        }\n        return times;\n    }\n}\n```
['C#']