上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 51 下一页
摘要: 思路: 快慢指针,间隔n+1,当fast为None时,断掉slow.next:slow.next = slow.next.next。 阅读全文
posted @ 2020-05-09 13:46 人间烟火地三鲜 阅读(151) 评论(0) 推荐(0)
摘要: 方法一思路: 用现有节点存放结果(用l1存的,l1短则把l2的多余节点拼到l1上)。 方法二思路: 新建链表来存放结果。 阅读全文
posted @ 2020-05-09 13:41 人间烟火地三鲜 阅读(165) 评论(0) 推荐(0)
摘要: [toc] “ // ”运算:取整时保留整数的下界; 示例: \ 5//3 1 \ 5//3 2 int() 函数:是剪去小数部分,只保留前面的整数,即向零取整; 示例: \ int(5.3) 5 \ int(5.6) 5 round() 函数:遵循四舍五入的法则; 示例: \ round(5.3) 阅读全文
posted @ 2020-05-09 13:33 人间烟火地三鲜 阅读(1794) 评论(0) 推荐(0)
摘要: [toc] 定义 定义节点:数据域、指针域 head指针指向的是第一个节点。 定义单链表,及操作: python mylist = Node() mylist.next = head python node.next = head.next head.next = node python while 阅读全文
posted @ 2020-05-09 13:23 人间烟火地三鲜 阅读(294) 评论(0) 推荐(0)
摘要: 字典类型 1、有序 or 无序:无序 2、可变 or 不可变:可变类型 字典常用操作 1、取值 #用key取值 print(my_dict['name']) print(my_dict['hobbies'][0]) # 赋值,若字典中没有对应的key,则是添加;否则做修改 my_dict['sex' 阅读全文
posted @ 2020-04-29 11:38 人间烟火地三鲜 阅读(389) 评论(0) 推荐(0)
摘要: 代码一:用两个list 1 class Solution(object): 2 # 用两个list 3 def countLargestGroup(self, n): 4 """ 5 :type n: int 6 :rtype: int 7 """ 8 # 存放不同的数位和 9 listkey = 阅读全文
posted @ 2020-04-29 10:30 人间烟火地三鲜 阅读(233) 评论(0) 推荐(0)
摘要: 思路: 果然做题最难得还是读懂题意:遍历arr,遇到一个0则复制一个,最后arr长度不变;所以: 遍历arr,在下标为i处遇到0则insert(i,0),并将最后一个元素pop掉,以保证arr长度不变; 1 class Solution(object): 2 def duplicateZeros(s 阅读全文
posted @ 2020-04-29 10:23 人间烟火地三鲜 阅读(128) 评论(0) 推荐(0)
摘要: 思路: 1、按字符串长度升序排列,以排序后的首字符串中的元素为目标;2、遍历首字符串,每一趟遍历前要统计当前字符ch分别在首字符串和返回值ans中的个数: numi和numans;3、若ch未在ans里出现过(即numans<1),且在剩余字符串中都出现过,则将ch追加到ans中; 遍历剩余字符串时 阅读全文
posted @ 2020-04-29 10:18 人间烟火地三鲜 阅读(186) 评论(0) 推荐(0)
摘要: 代码一:暴力超时。 class Solution(object): # 暴力超时 def sumEvenAfterQueries(self, A, queries): """ :type A: List[int] :type queries: List[List[int]] :rtype: List 阅读全文
posted @ 2020-04-29 10:05 人间烟火地三鲜 阅读(168) 评论(0) 推荐(0)
摘要: 代码一: 1 class Solution(object): 2 def sortedSquares(self, A): 3 """ 4 :type A: List[int] 5 :rtype: List[int] 6 """ 7 ans=[] 8 for i in range(len(A)): 9 阅读全文
posted @ 2020-04-29 10:02 人间烟火地三鲜 阅读(138) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 51 下一页