最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

global是全局變量為什么改變不了tell的值為1

2023-08-25 13:50 作者:曉吐災(zāi)子  | 我要投稿

# global tell

class Solution:

? ? def isBalanced(self, root: TreeNode) -> bool:

? ? ? ?

? ? ? ? tell=0

? ? ? ? def f1(root:TreeNode):

? ? ? ? ? ? nonlocal tell

? ? ? ? ? ? if root is None:

? ? ? ? ? ? ? ? return 0

? ? ? ? ? ? left=f1(root.left)

? ? ? ? ? ? right=f1(root.right)

? ? ? ? ? ? # print(type(right))

? ? ? ? ? ? if abs(left -right)>1:

? ? ? ? ? ? ? ? tell=1

? ? ? ? ? ? ? ? return 2


? ? ? ? ? ? else :

? ? ? ? ? ? ? ? return max(left,right)+1

? ? ? ? f1(root)

? ? ? ? if tell:

? ? ? ? ? ? return False

? ? ? ? else:

? ? ? ? ? ? return True



global是全局變量為什么改變不了tell的值為1的評論 (共 條)

分享到微博請遵守國家法律
华坪县| 平阳县| 旬邑县| 曲水县| 平昌县| 陈巴尔虎旗| 宜宾县| 岫岩| 神农架林区| 察哈| 扎赉特旗| 修武县| 高陵县| 建平县| 防城港市| 赤峰市| 桦甸市| 定日县| 宜宾市| 尚志市| 河北区| 宜君县| 永康市| 绥江县| 磐安县| 安远县| 弥渡县| 苏尼特右旗| 崇文区| 钟祥市| 类乌齐县| 皋兰县| 武功县| 上虞市| 建瓯市| 德格县| 巩留县| 武冈市| 三亚市| 潢川县| 新平|