IT入门 > 面试题 > python题库 > 编程题 >

  • 两个字符串是否是变位词

    日期:2019-07-27 11:25:24 点击:1534 好评:0

    class Anagram: """ @:param s1: The first string @:param s2: The second string @:return true or false """ def Solution1(s1,s2): alist = list(s2) pos1 = 0 stillOK = True while pos1...

  • 单链表逆置

    日期:2019-07-27 11:24:41 点击:2074 好评:0

    class Node(object): def __init__(self, data=None, next=None): self.data = data self.next = nextlink = Node(1, Node(2, Node(3, Node(4, Node(5, Node(6, Node(7, Node(8, Node(9)))))))))def rev(link): pre = link cur = link.next pre.next = None w...

  • 前序中序求后序

    日期:2019-07-27 11:24:17 点击:6953 好评:0

    推荐: http://blog.csdn.net/hinyunsin/article/details/6315502 def rebuild(pre, center): if not pre: return cur = Node(pre[0]) index = center.index(pre[0]) cur.left = rebuild(pre[1:index + 1], center[:index]) cur.right = rebuild(pre[index +...

  • 求两棵树是否相同

    日期:2019-07-27 11:23:39 点击:1822 好评:0

    def isSameTree(p, q): if p == None and q == None: return True elif p and q : return p.val == q.val and isSameTree(p.left,q.left) and isSameTree(p.right,q.right) else : return False...

  • 求最大树深

    日期:2019-07-27 11:23:05 点击:7067 好评:0

    def maxDepth(root): if not root: return 0 return max(maxDepth(root.left), maxDepth(root.right)) + 1...

  • 前中后序遍历

    日期:2019-07-27 11:22:44 点击:4283 好评:0

    深度遍历改变顺序就OK了 #coding:utf-8#二叉树的遍历#简单的二叉树节点类class Node(object): def __init__(self,value,left,right): self.value = value self.left = left self.right = right#中序遍历:遍历左子树,访问当...

  • 深度遍历

    日期:2019-07-27 11:22:15 点击:2241 好评:0

    def deep(root): if not root: return print root.data deep(root.left) deep(root.right)if __name__ == '__main__': lookup(tree) deep(tree)...

  • 二叉树节点

    日期:2019-07-27 11:21:50 点击:1953 好评:0

    class Node(object): def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = righttree = Node(1, Node(3, Node(7, Node(0)), Node(6)), Node(2, Node(5), Node(4)))...

  • 广度遍历和深度遍历二叉树

    日期:2019-07-27 11:21:31 点击:6697 好评:0

    给定一个数组,构建二叉树,并且按层次打印这个二叉树...

  • 找零问题

    日期:2019-07-27 11:20:56 点击:3518 好评:0

    #coding:utf-8#values是硬币的面值values = [ 25, 21, 10, 5, 1]#valuesCounts 钱币对应的种类数#money 找出来的总钱数#coinsUsed 对应于目前钱币总数i所使用的硬币数目def coinChange(values,valuesCounts,money,coin...

广告位API接口通信错误,查看德得广告获取帮助