From 83777675eec22d4a801a88652b33cd9e9a450918 Mon Sep 17 00:00:00 2001 From: xqm32 <458173774@qq.com> Date: Tue, 25 Jul 2023 20:34:05 +0800 Subject: [PATCH] leetcode: finished #2717 --- content/leetcode/2023/7.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/content/leetcode/2023/7.md b/content/leetcode/2023/7.md index ba1c2e245..b46fe2334 100644 --- a/content/leetcode/2023/7.md +++ b/content/leetcode/2023/7.md @@ -3,6 +3,32 @@ title: "2023.7" draft: false --- +# 2023.7.25 + +```python +# +# @lc app=leetcode.cn id=2717 lang=python3 +# +# [2717] 半有序排列 +# + +# @lc code=start +from typing import List + + +class Solution: + def semiOrderedPermutation(self, nums: List[int]) -> int: + a = nums.index(1) + b = list(reversed(nums)).index(len(nums)) + c = 0 + if (a - nums.index(len(nums))) > 0: + c = 1 + return a + b - c + + +# @lc code=end +``` + # 2023.7.24 ```python