leetcode
卡其1991
这个作者很懒,什么都没留下…
展开
-
130. Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O X转载 2016-03-02 13:28:57 · 241 阅读 · 0 评论 -
200. Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu转载 2016-03-02 13:46:56 · 297 阅读 · 0 评论 -
46. Permutations
Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].Subs转载 2016-03-02 14:15:39 · 267 阅读 · 0 评论 -
131. Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","转载 2016-03-02 14:39:19 · 277 阅读 · 0 评论 -
112. Path Sum
方法一:使用递归的策略方法二:使用深度优先遍历(借助栈来实现)原创 2016-02-29 17:23:45 · 217 阅读 · 0 评论 -
103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given bin原创 2016-02-27 15:23:02 · 264 阅读 · 0 评论 -
113. Path Sum II
方法一:与112中的第二种方法相同,利用栈对二叉树进行深度优先搜索。注意叶节点在上一阶段已经被加入ans中,所以当到达叶节点时不需要再次加叶节点的值。方法二:使用递归的方法,效果更好,空间复杂度也低原创 2016-02-29 18:46:58 · 203 阅读 · 0 评论