摘要:
交叉链表求交点 1 class ListNode: 2 def __init__(self, x): 3 self.val = x 4 self.next = None 5 def node(l1, l2): 6 length1, lenth2 = 0, 0 7 # 求两个链表长度 8 while 阅读全文
摘要:
1.尾递归 1 def _recursion_merge_sort2(l1, l2, tmp): 2 if len(l1) == 0 or len(l2) == 0: 3 tmp.extend(l1) 4 tmp.extend(l2) 5 return tmp 6 else: 7 if l1[0] 阅读全文
摘要:
1 直接创建 dict = {'name':'earth', 'port':'80'} 2 工厂方法 items=[('name','earth'),('port','80')] dict2=dict(items) dict1=dict((['name','earth'],['port','80'] 阅读全文
摘要:
1->2->3->4 转换成 2->1->4->3 class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param a ListNode # @return a ListNod 阅读全文
摘要:
1.用集合 2.list(set(l)) 用字典 l1 = ['b','c','d','b','c','a','a'] l2 = {}.fromkeys(l1).keys() print l2 3.用字典并保持顺序l1 = ['b','c','d','b','c','a','a'] l2 = lis 阅读全文