递归 一棵树要么是空树,要么有两个指针,每个指针指向一棵树.树是一种递归结构,很多树的问题可以使用递归来处理. 1. 树的高度 104. Maximum Depth of Binary Tree (Easy) Leetcode / 力扣 class Solution { public int maxDepth(TreeNode root) { if(root==null)return 0; return Math.max(maxDepth(root.left),maxDepth(root.rig…
一.数据筛选: 处理方式: 1.filter函数在py3,返回的是个生成式. from random import randint data = [randint(-100,100) for i in range(10)] data2 = [34, -59, -13, 96, -78, 38, 89, -96, -79, 98] info = filter(lambda x:x>0,data2) for i in info: print(i) 2.列表解析 from random import…
Dynamic Rankings Time Limit: 10 Seconds Memory Limit: 32768 KB The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They…