上一页 1 ··· 12 13 14 15 16
摘要: Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should run inO(n)time and uses constant space.ref:http://www.cnblogs.com/AnnieKim/archive/2013/04/21/3034631.html虽然不能再另外开辟非常数级的额外空间,但是可以在输入数组上就地进行swap操作。思路:交换数 阅读全文
posted @ 2014-01-24 02:52 Razer.Lu 阅读(208) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int atoi(String str) { if(str.length() == 0 || str == null){ return 0; } str = str.trim(); boolean positiveflag = true; if(str.charAt(0) == '+'){ str = str.substring(1); }else if(str.cha... 阅读全文
posted @ 2014-01-23 16:04 Razer.Lu 阅读(169) 评论(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:bool i 阅读全文
posted @ 2014-01-23 14:36 Razer.Lu 阅读(262) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public double findMedianSortedArrays(int A[], int B[]) { int aLen = A.length; int bLen = B.length; if((aLen+bLen) % 2 == 0){ return (getKthElement(A, 0, aLen-1, B, 0, bLen-1, (aLen+bLen)/2) ... 阅读全文
posted @ 2014-01-23 14:30 Razer.Lu 阅读(207) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16