摘要:
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example, 题意: 给定固定长度的滑动窗口,更新滑动窗口中 阅读全文
摘要:
Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Example 2: Follow up: A 阅读全文
摘要:
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 阅读全文
摘要:
Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree have the same value. Example : 题意: 给定一 阅读全文
摘要:
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. N 阅读全文
摘要:
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
摘要:
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Exampl 阅读全文
摘要:
Numbers can be regarded as product of its factors. For example, Write a function that takes an integer n and return all possible combinations of its f 阅读全文
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 1 Input: 2 [ 3 1->4->5, 4 1->3->4, 5 2->6 6 ] 7 Out 阅读全文
摘要:
Given a collection of intervals, merge all overlapping intervals. Example 1: 题意: 给定一些区间,将重叠部分合并。 思路: 将原interval集合里,给定区间按照start开头值的从小到大排序 建一个新的interval 阅读全文