摘要:
Then-queens puzzle is the problem of placingnqueens on ann�nchessboard such that no two queens attack each other.Given an integern, return all distinct solutions to then-queens puzzle.Each solution contains a distinct board configuration of then-queens' placement, where'Q'and'.'b 阅读全文
posted @ 2013-09-22 06:00
LEDYC
阅读(179)
评论(0)
推荐(0)
摘要:
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.---/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */publ... 阅读全文
posted @ 2013-09-22 02:05
LEDYC
阅读(189)
评论(0)
推荐(0)
摘要:
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.---/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ... 阅读全文
posted @ 2013-09-22 02:02
LEDYC
阅读(128)
评论(0)
推荐(0)
摘要:
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its zigzag level order traversal as:[ [3], ... 阅读全文
posted @ 2013-09-22 01:49
LEDYC
阅读(181)
评论(0)
推荐(0)
摘要:
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its level order traversal as:[ [3], [9,20], [15,7]]confused what"{1,#,2,3}"means?> read more . 阅读全文
posted @ 2013-09-22 01:36
LEDYC
阅读(177)
评论(0)
推荐(0)
摘要:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3Note:Bonus points if you could solve it both recursively and iterati... 阅读全文
posted @ 2013-09-22 01:29
LEDYC
阅读(141)
评论(0)
推荐(0)
浙公网安备 33010602011771号