08 2020 档案

环形链表()
摘要:法一: class Solution: def hasCycle(self, head: ListNode) -> bool: a = set() while head: if head in a: return True a.add(head) head = head.next return Fa 阅读全文

posted @ 2020-08-19 16:22 不要挡着我晒太阳 阅读(96) 评论(0) 推荐(0) 编辑

合并两个有序链表(21)
摘要:# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None 法一: class Solution: def mergeTwoList 阅读全文

posted @ 2020-08-19 11:28 不要挡着我晒太阳 阅读(109) 评论(0) 推荐(0) 编辑

删除链表倒数第n个节点(19)
摘要:法一:# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFrom 阅读全文

posted @ 2020-08-17 17:16 不要挡着我晒太阳 阅读(54) 评论(0) 推荐(0) 编辑

Z字形变换(6)
摘要:class Solution: def convert(self, s: str, numRows: int) -> str: if numRows < 2: return s res = ["" for _ in range(numRows)] i, flag = 0, -1 for c in s 阅读全文

posted @ 2020-08-13 11:21 不要挡着我晒太阳 阅读(95) 评论(0) 推荐(0) 编辑

三数之和(15)
摘要:class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ nums.sort() if not nums or len(nums)<3: return 阅读全文

posted @ 2020-08-11 17:32 不要挡着我晒太阳 阅读(72) 评论(0) 推荐(0) 编辑

两数之和(1)
摘要:法一: class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: ret = [] for i in range(len(nums)): for j in range(1,len(nums)-i): if 阅读全文

posted @ 2020-08-11 14:22 不要挡着我晒太阳 阅读(66) 评论(0) 推荐(0) 编辑

加一(66)
摘要:法一: class Solution: def plusOne(self, digits: List[int]) -> List[int]: length = len(digits) res = 0 for i in digits: if digits[-1]!=9: if length!=1: r 阅读全文

posted @ 2020-08-05 15:48 不要挡着我晒太阳 阅读(165) 评论(0) 推荐(0) 编辑

原地删除(27)
摘要:法一: class Solution: def removeElement(self, nums: List[int], val: int) -> int: for i in range(len(nums)-1, -1, -1): if(nums[i] == val): nums.pop(i) re 阅读全文

posted @ 2020-08-03 13:48 不要挡着我晒太阳 阅读(113) 评论(0) 推荐(0) 编辑

旋转数组(189)
摘要:法一: class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ n = len(nums) k % 阅读全文

posted @ 2020-08-03 10:39 不要挡着我晒太阳 阅读(112) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示