摘要: 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) 编辑
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as illustrated below.[[0,0,0],[0, 阅读全文
posted @ 2012-10-23 00:30 ETCOW 阅读(255) 评论(0) 推荐(0) 编辑
摘要: M*N grids from top-left to bottom-right find all the paths. 1 public static int UniquePaths(int m, int n) 2 { 3 int ret = 0; 4 FindAllPaths(m, n, ref ret); 5 return ret; 6 } 7 8 public static void FindAllPaths(int m, int n, ref int... 阅读全文
posted @ 2012-10-23 00:21 ETCOW 阅读(263) 评论(0) 推荐(0) 编辑