Semi ordered permutation in C
Code


# Code
```c []
int semiOrderedPermutation(int* nums, int numsSize) {
    int index1, index2;
    for (int i = 0; i < numsSize; i++) {
        if (nums[i] == 1)
            index1 = i;
        if (nums[i] == numsSize)
            index2 = i;
    }
    if (index1 < index2)
        return index1 + ((numsSize - 1) - index2);
    return index1 + (((numsSize - 1) - index2)) - 1;
}
```
['C']