摘要: Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,2,3]Solution 1: # Definitio 阅读全文
posted @ 2019-10-18 11:22 xuan_abc 阅读(85) 评论(0) 推荐(0)
摘要: Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any 阅读全文
posted @ 2019-10-18 10:58 xuan_abc 阅读(105) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2019-10-17 10:33 xuan_abc 阅读(93) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2019-10-16 10:58 xuan_abc 阅读(109) 评论(0) 推荐(0)
摘要: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2019-10-16 10:11 xuan_abc 阅读(87) 评论(0) 推荐(0)
摘要: Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the 阅读全文
posted @ 2019-10-16 09:28 xuan_abc 阅读(117) 评论(0) 推荐(0)
摘要: Given a string s , find the length of the longest substring t that contains at most 2 distinct characters. Example 1: Example 2: 阅读全文
posted @ 2019-10-15 09:03 xuan_abc 阅读(99) 评论(0) 推荐(0)
摘要: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], 阅读全文
posted @ 2019-10-14 05:10 xuan_abc 阅读(144) 评论(0) 推荐(0)
摘要: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文
posted @ 2019-10-14 03:16 xuan_abc 阅读(140) 评论(0) 推荐(0)
摘要: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu 阅读全文
posted @ 2019-10-13 23:13 xuan_abc 阅读(125) 评论(0) 推荐(0)