摘要:
思路一: 本题nums里面的数由于都是正数,所以可以用两个指针 start 和 end = 0。end++向后寻找,直到 start和end之间的sum>=s。例如 nums = [2, 3, 1, 2, 4, 3], s = 7。这一步结束时找到了start = 0 的最短的满足条件的subarr 阅读全文
摘要:
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example, 思路:本题比较简单,在__init__的时候, 阅读全文
摘要:
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa 阅读全文
摘要:
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文
摘要:
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
摘要:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
摘要:
思路1: 递归,如果 p = q, 那么判段 sameTree(p.left)==sameTree(q.left) and sameTree(p.right) = sameTree(q.right) 思路二: 如果两个树相同,说明按照一定的方式遍历这两个树,应该得到一样的结果。这里用的方法是使用st 阅读全文
摘要:
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
摘要:
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
摘要:
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. Not 阅读全文