From 78138557af92845447874736c68790d4fcf5f55d Mon Sep 17 00:00:00 2001 From: Lebhroryi Date: 2020年2月26日 23:44:36 +0800 Subject: [PATCH] add 80 & 81 --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index ff38d00..e9d0752 100644 --- a/README.md +++ b/README.md @@ -690,6 +690,23 @@ class Solution: from itertools import combinations return sum([list(combinations(nums, i)) for i in range(len(nums) + 1)], []) ``` + +## [80. 删除排序数组中的重复项 II 4行](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array-ii/) +```python +def removeDuplicates(nums: [int]) -> int: + for i in range(len(nums)-3, -1, -1): + if nums[i] == nums[i+1] and nums[i] == nums[i+2]: + nums.pop(i) + return len(nums) +``` +- 从尾部开始考虑 + +## [81. 搜索旋转排序数组 II 1行](https://leetcode-cn.com/problems/search-in-rotated-sorted-array-ii/) +```python +def search(nums: [int], target: int) -> bool: + return target in nums +``` + ## [83. Remove Duplicates from Sorted List 3行](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) ```python # Definition for singly-linked list.

AltStyle によって変換されたページ (->オリジナル) /