上一页 1 2 3 4 5 6 ··· 21 下一页

2020年9月1日

Python中的函数和方法

摘要: 在Python中,对函数和方法都有明确的规定: 函数function A series of statements which returns some value to a caller. It can also be passed zero or more arguments which may 阅读全文

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

2020年8月19日

环形链表()

摘要: 法一: 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 不要挡着我晒太阳 阅读(95) 评论(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 不要挡着我晒太阳 阅读(106) 评论(0) 推荐(0) 编辑

2020年8月17日

删除链表倒数第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 不要挡着我晒太阳 阅读(53) 评论(0) 推荐(0) 编辑

2020年8月13日

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 不要挡着我晒太阳 阅读(94) 评论(0) 推荐(0) 编辑

2020年8月11日

三数之和(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 不要挡着我晒太阳 阅读(70) 评论(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 不要挡着我晒太阳 阅读(65) 评论(0) 推荐(0) 编辑

2020年8月5日

加一(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 不要挡着我晒太阳 阅读(163) 评论(0) 推荐(0) 编辑

2020年8月3日

原地删除(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 不要挡着我晒太阳 阅读(112) 评论(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 不要挡着我晒太阳 阅读(110) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 21 下一页

导航