摘要: 简单题。先把横的竖的扫一下,然后按照每个3*3的小格扫一遍。import java.util.HashSet;public class Solution { public boolean isValidSudoku(char[][] board) { // Start typin... 阅读全文
posted @ 2013-08-04 15:58 阿牧遥 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 二分查找的小变化。简单题。public class Solution { public int searchInsert(int[] A, int target) { // Start typing your Java solution below // DO NOT write main() function return searchInsert(A, target, 0, A.length - 1); } public int searchInsert(int[] A, int target, int left, int... 阅读全文
posted @ 2013-08-04 15:34 阿牧遥 阅读(192) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/dwdxdy/archive/2012/07/28/2613135.html利用rand5()产生rand7().rand5()产生1到5的整数,rand7()产生1到7的整数.解决思路与上述的练习题是一样的.利用rand5()产生的一个整数空间,然后将其映射到[1,7]的整数空间上,映射时保证概率相等,且等于1/7.下面介绍几个有意思的实现.1.利用预置数组该方法简单,易理解,但是不具扩展性,需要额外存储空间.int rand7(){ int vals[5][5] = { {1,2,3,4,5}, {6,7,1,... 阅读全文
posted @ 2013-08-04 00:21 阿牧遥 阅读(515) 评论(0) 推荐(0) 编辑