1 2 3 4 5 ··· 10 下一页
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its bottom-up level order traversal as:[ [15,7] [9,20], [3],] 1 ... 阅读全文
posted @ 2012-10-25 00:38 ETCOW 阅读(414) 评论(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]] 1 public static List<List<int>> B... 阅读全文
posted @ 2012-10-25 00:28 ETCOW 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 1 public static List<int> BinaryTreeInorderTraveral(BTNode root) 2 { 3 List<int> ret = new List<int>(); 4 BinaryTreeInorderTraveralHelper(root, ret); 5 return ret; 6 } 7 8 public static void BinaryTreeInorderTraveralHelper(BTNode ... 阅读全文
posted @ 2012-10-24 23:41 ETCOW 阅读(324) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees ofeverynode never differ by more than 1. 1 public static bool BalancedBinaryTree(BTNode root) 2 { 3 i... 阅读全文
posted @ 2012-10-24 23:36 ETCOW 阅读(336) 评论(0) 推荐(0) 编辑
摘要: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I GY I RAnd then read line by line: "PAHNAPLSIIGYIR"Write the code that will take a string 阅读全文
posted @ 2012-10-23 05:09 ETCOW 阅读(546) 评论(0) 推荐(0) 编辑
摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.For example,Given board =[[& 阅读全文
posted @ 2012-10-23 05:00 ETCOW 阅读(876) 评论(0) 推荐(0) 编辑
摘要: Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:boo 阅读全文
posted @ 2012-10-23 04:40 ETCOW 阅读(492) 评论(0) 推荐(0) 编辑
摘要: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'. 1 public static bool ValidSudoku(List<List<char>> board) 2 { 3 for (int i = 0; i < board.Count; i++) 4... 阅读全文
posted @ 2012-10-23 03:45 ETCOW 阅读(546) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]&qu 阅读全文
posted @ 2012-10-23 03:39 ETCOW 阅读(439) 评论(0) 推荐(0) 编辑
摘要: Validate if a given string is numericSome examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before i 阅读全文
posted @ 2012-10-23 00:49 ETCOW 阅读(351) 评论(0) 推荐(0) 编辑
1 2 3 4 5 ··· 10 下一页