摘要:
104. Maximum Depth of Binary Tree 和111很像,只是递归的结构略有不同,可简单画图分析,求最大深度可以直接返回1+max(左子树深度,右子树深度),但是求最小深度时不可以,需要分别考虑左右子树为空的情况。可以举个反例子,比如,单斜树。 1 class Solutio 阅读全文
摘要:
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文
摘要:
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function sho 阅读全文