摘要: code class BinaryTree: def __init__(self, rootObj): self.key = rootObj self.leftChild = None self.rightChild = None def insertLeft(self, newNode): if 阅读全文
posted @ 2020-10-04 16:40 anobscureretreat 阅读(191) 评论(0) 推荐(0)
摘要: code ''' 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字, 例如,如果输入如下矩阵: [[ 1, 2, 3, 4], [ 5, 6, 7, 8], [ 9, 10, 11, 12], [13, 14, 15, 16]] 则依次打印出数字 1,2,3,4,8,12,16,15,1 阅读全文
posted @ 2020-10-04 12:40 anobscureretreat 阅读(315) 评论(0) 推荐(0)
摘要: code def reverse_str(tmp): alist=list(tmp) startIndex = 0 endIndex = len(alist) - 1 while startIndex < endIndex: alist[startIndex], alist[endIndex] = 阅读全文
posted @ 2020-10-04 11:21 anobscureretreat 阅读(282) 评论(0) 推荐(0)
摘要: code class Solution: # 按照书上的方法进行编写 # 因为Python的字符串结束没有结束符, 所以需要判断最后的pEnd是否已经指到最后一个字符 # 如果已经指到最后一个字符, 则直接在复制之后跳出循环 # 测试用例'I am a student.'和' '和'' def Re 阅读全文
posted @ 2020-10-04 11:13 anobscureretreat 阅读(526) 评论(0) 推荐(0)
摘要: code class Node: def __init__(self, initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return sel 阅读全文
posted @ 2020-10-04 00:16 anobscureretreat 阅读(205) 评论(0) 推荐(0)