摘要: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules (http://sudoku.com.au/TheRules.aspx). The Sudoku board could be partially filled, where empty cells are filled with the character '.'. Solution: 1. Traverse the Sudoku only once. 2. Bit manipulation. Use only one bit .. 阅读全文
posted @ 2014-04-08 05:52 beehard 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space? A straight forward solution using O(mn) space is probably a bad idea. A simple improvement uses O(m + n) space, but still not the best solution. Could you devise a consta 阅读全文
posted @ 2014-04-08 04:26 beehard 阅读(114) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? Solution: 1. Use fo 阅读全文
posted @ 2014-04-08 03:58 beehard 阅读(112) 评论(0) 推荐(0) 编辑