上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
摘要: Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible 阅读全文
posted @ 2017-01-02 11:24 lettuan 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4], 阅读全文
posted @ 2017-01-02 10:20 lettuan 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2016-12-28 06:28 lettuan 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(145) 评论(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 阅读(167) 评论(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 阅读(373) 评论(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 阅读(120) 评论(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 阅读(128) 评论(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 阅读(123) 评论(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 阅读(116) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页