摘要: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/ve 阅读全文
posted @ 2016-12-27 14:51 lettuan 阅读(152) 评论(0) 推荐(0)
摘要: Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. Note: Example 1: Examp 阅读全文
posted @ 2016-12-27 13:25 lettuan 阅读(174) 评论(0) 推荐(0)
摘要: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t 阅读全文
posted @ 2016-12-27 11:06 lettuan 阅读(376) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum 阅读全文
posted @ 2016-12-27 11:01 lettuan 阅读(122) 评论(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. F 阅读全文
posted @ 2016-12-27 10:54 lettuan 阅读(132) 评论(0) 推荐(0)
摘要: Find the sum of all left leaves in a given binary tree. Example: 注意: 如果想在辅助函数里维护一个变量为sum of left leaves。这个变量需要是一个全局变量。 可以用如下似乎递归求解。 阅读全文
posted @ 2016-12-27 10:13 lettuan 阅读(125) 评论(0) 推荐(0)
摘要: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 本题可以用DFS或者BFS。 解法一: DFS 阅读全文
posted @ 2016-12-27 06:55 lettuan 阅读(120) 评论(0) 推荐(0)