摘要: class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ i = 0 j = len(s) - 1 while i 阅读全文
posted @ 2022-05-04 03:56 stronger_el 阅读(23) 评论(0) 推荐(0)
摘要: # 前后两个指针往中间靠class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: i = 0 j = len(numbers) - 1 result = [] while i < j: if num 阅读全文
posted @ 2022-05-04 03:06 stronger_el 阅读(25) 评论(0) 推荐(0)
摘要: # 暴力法 class Solution: def minimumCardPickup(self, cards: List[int]) -> int: min_card = len(cards) find = False if len(cards) == 1: return - 1 i = 0 wh 阅读全文
posted @ 2022-05-01 11:37 stronger_el 阅读(41) 评论(0) 推荐(0)
摘要: class Solution: def removeDigit(self, number: str, digit: str) -> str: max_result = 0 for i in range(0, len(number)): if number[i] == digit: if i == 0 阅读全文
posted @ 2022-05-01 11:07 stronger_el 阅读(69) 评论(0) 推荐(0)
摘要: class Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ i, j = 0, 0 while j < len 阅读全文
posted @ 2022-04-30 18:06 stronger_el 阅读(22) 评论(0) 推荐(0)
摘要: class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ if k >= len(nums): ro 阅读全文
posted @ 2022-04-30 16:31 stronger_el 阅读(22) 评论(0) 推荐(0)
摘要: class Solution: def sortedSquares(self, nums: List[int]) -> List[int]: if len(nums) == 0: return [] if len(nums) == 1: return [nums[0] ** 2] result = 阅读全文
posted @ 2022-04-29 22:22 stronger_el 阅读(37) 评论(0) 推荐(0)
摘要: class Solution: def searchInsert(self, nums: List[int], target: int) -> int: if len(nums) == 0: return 0 left = 0 right = len(nums) - 1 result = 0 whi 阅读全文
posted @ 2022-04-29 17:28 stronger_el 阅读(17) 评论(0) 推荐(0)
摘要: # The isBadVersion API is already defined for you. # @param version, an integer # @return an integer # def isBadVersion(version): class Solution: def 阅读全文
posted @ 2022-04-27 19:01 stronger_el 阅读(7) 评论(0) 推荐(0)
摘要: 【递归】 class Solution: def search(self, nums: List[int], target: int) -> int: if len(nums) == 0: return -1 mid = int(len(nums)-1 / 2) result = 0 if nums 阅读全文
posted @ 2022-04-27 18:20 stronger_el 阅读(17) 评论(0) 推荐(0)