摘要:
阅读全文
摘要:
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR 阅读全文
摘要:
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla 阅读全文
摘要:
讲解一: 用一个数组来存 the smallest tail of all increasing subsequences with length i+1 in tails[i]. For example, say we have nums = [4,5,6,3], then all the ava 阅读全文
摘要:
Be careful, when calculate B, you should exclude A's cases 阅读全文
摘要:
Referring this post: https://leetcode.com/problems/serialize-and-deserialize-binary-tree/discuss/74253/Easy-to-understand-Java-Solution But instead us 阅读全文
摘要:
递归法 复杂度 时间O(n) 空间O(h) 思路 因为要找最长的连续路径,我们在遍历树的时候需要两个信息,一是目前连起来的路径(curLen)有多长(以当前节点为终点),二是目前路径的上一个节点的值(preVal)。 每一次递归,先检查当前节点是否比上一节点大1, 是,curLen++, 否curL 阅读全文