Skip to content

Commit

Permalink
[Must Review] Dealing with middle area
Browse files Browse the repository at this point in the history
  • Loading branch information
kaestro committed May 1, 2024
1 parent a5a04cd commit eb87856
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Daily Practices/May/Week 1st/[Must Review]2717 - LeetCode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://leetcode.com/problems/semi-ordered-permutation/description/

from typing import List

class Solution:
def semiOrderedPermutation(self, nums: List[int]) -> int:
n = len(nums)
i, j = nums.index(1), nums.index(n)
return i + n - 1 - j - (i > j)

0 comments on commit eb87856

Please sign in to comment.