2717. Semi-Ordered Permutation
You are given a 0-indexed permutation of
n
integersnums
.A permutation is called semi-ordered if the first number equals
1
and the last number equalsn
. You can perform the below operation as many times as you want until you makenums
a semi-ordered permutation:
- Pick two adjacent elements in
nums
, then swap them.Return the minimum number of operations to make
nums
a semi-ordered permutation.A permutation is a sequence of integers from
1
ton
of lengthn
containing each number exactly once.
1 | class Solution { |