摘要:题目:给定一个二进制数组, 计算其中最大连续 1 的个数。 错解: class Solution: def findMaxConsecutiveOnes(self, nums: List[int]) -> int: maxcount=0 count=0 for i in nums: if i==1:
阅读全文
摘要:一、问题描述 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 二、代码实现: class Solution: def Sum_Solution(self, n): if n ==0: return 0 e
阅读全文
摘要:一、问题描述 将源二叉树转换成镜像二叉树,主要是左右节点互换 二、代码实现: class Solution: def Mirror(self, root): # write code here if not root: return root root.left,root.right=root.ri
阅读全文