摘要:
题目描述: 第一次提交: class Solution(object): def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ a = 0 b = 阅读全文
摘要:
题目描述: 方法一:排序输出中位数 class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return None nums.sor 阅读全文
摘要:
题目描述: 解法一:迭代 class Solution: def reverseList(self, head: ListNode) -> ListNode: pre = None cur = head while cur: tmp = cur.next cur.next = pre cur,pre 阅读全文
摘要:
题目描述: 方法:#在改pre链表时 head中的值也改变 class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode "" 阅读全文
摘要:
题目描述: 方法一: class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ a,b = headA,head 阅读全文
摘要:
题目描述: 方法一: class Solution(object): def hasCycle(self, head): """ :type head: ListNode :rtype: bool """ while head: if head.val == "daafas": return Tru 阅读全文
摘要:
https://mp.weixin.qq.com/s/jluii9YIvfhKd_tPecfTaw 阅读全文
摘要:
题目描述: 第一次提交: class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: j,x = 0,1 l = [] if matrix==[]: return [] m = len(matrix) n 阅读全文
摘要:
题目描述: 参考后的提交: class Solution: def generateMatrix(self, n: int): #l = [[0] * n] * n 此创建方法错误 l = [[] for i in range(n)] for i in range(n): for j in rang 阅读全文
摘要:
题目描述: 第一次提交;(超时): class Solution: def countPrimes(self, n: int) -> int: count = 0 for i in range(2,n): for j in range(2,i+1): if i%j == 0 and j!=i: br 阅读全文