11 2020 档案
摘要:You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following defin
阅读全文
摘要:Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all l
阅读全文
摘要:Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result
阅读全文
摘要:描述 property() 函数的作用是在新式类中返回属性值。大概意思就是让方法变成一个属性 语法 以下是 property() 方法的语法: class property([fget[, fset[, fdel[, doc]]]]) 参数 fget -- 获取属性值的函数 fset -- 设置属性
阅读全文
摘要:描述 classmethod 修饰符对应的函数不需要实例化,不需要 self 参数,但第一个参数需要是表示自身类的 cls 参数,可以来调用类的属性,类的方法,实例化对象等。 语法 classmethod 语法: classmethod 参数 无。 返回值 返回函数的类方法。 实例 以下实例展示了
阅读全文
摘要:staticmethod()是python内置函数, 该方法不强制要求传递参数,如下声明一个静态方法: class C(object): @staticmethod def f(arg1, arg2, ...): ... 以上实例声明了静态方法 f,从而可以实现实例化使用 C().f(),当然也可以
阅读全文