摘要: 题目描述: 第一次提交: class Solution(object): def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ a = 0 b = 阅读全文
posted @ 2019-03-20 08:25 oldby 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:排序输出中位数 class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return None nums.sor 阅读全文
posted @ 2019-03-19 20:24 oldby 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一:迭代 class Solution: def reverseList(self, head: ListNode) -> ListNode: pre = None cur = head while cur: tmp = cur.next cur.next = pre cur,pre 阅读全文
posted @ 2019-03-19 20:04 oldby 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法:#在改pre链表时 head中的值也改变 class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode "" 阅读全文
posted @ 2019-03-18 21:33 oldby 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ a,b = headA,head 阅读全文
posted @ 2019-03-18 20:35 oldby 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: class Solution(object): def hasCycle(self, head): """ :type head: ListNode :rtype: bool """ while head: if head.val == "daafas": return Tru 阅读全文
posted @ 2019-03-18 19:45 oldby 阅读(632) 评论(0) 推荐(0) 编辑
摘要: https://mp.weixin.qq.com/s/jluii9YIvfhKd_tPecfTaw 阅读全文
posted @ 2019-03-18 14:41 oldby 阅读(546) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: j,x = 0,1 l = [] if matrix==[]: return [] m = len(matrix) n 阅读全文
posted @ 2019-03-18 14:14 oldby 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 参考后的提交: 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 阅读全文
posted @ 2019-03-18 12:30 oldby 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交;(超时): 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 阅读全文
posted @ 2019-03-17 17:52 oldby 阅读(215) 评论(0) 推荐(0) 编辑