摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2014-06-29 17:53 OpenSoucre 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 参考Babylonian method(x0 越接*S的*方根越好)class Solution {public: int sqrt(double x) { if(x == 0) return 0; double root = x/2, tolerance = 1.... 阅读全文
posted @ 2014-06-29 17:30 OpenSoucre 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x,n).明显的二分解决由于n不可能总是偶数, 如果n是正奇数,那么n个x的乘积等于两部分的乘积再乘以x 如果n是负奇数,那么n个x的乘积等于两部分乘积再乘以1/xclass Solution {public: double pow(double x, int ... 阅读全文
posted @ 2014-06-29 16:45 OpenSoucre 阅读(169) 评论(0) 推荐(0) 编辑
摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?矩阵的旋转如1 2 34 5 67 8... 阅读全文
posted @ 2014-06-29 16:34 OpenSoucre 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2014-06-29 16:14 OpenSoucre 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文
posted @ 2014-06-29 15:21 OpenSoucre 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 本题就是求所有连续子数列的和开始拿到题目还以为求的时数列子集的和,认真看到题目才知道是连续子数列循环遍历即可 int findSum(vector array) { int sum = 0; for(int i = 0 ; i < array.size(); ++... 阅读全文
posted @ 2014-06-29 14:47 OpenSoucre 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 典型的条件概率题目。事件A在另外一个事件B已经发生条件下的发生概率。条件概率表示为P(A|B),读作“在B条件下A的概率”。若只有两个事件A,B,那么,P(A|B)=P(AB)/P(B)本题的设事件Alice赢为B,事件Alice投掷数字x为A,则事件Alice投掷数字x且赢为AB则求在Alice赢... 阅读全文
posted @ 2014-06-29 14:44 OpenSoucre 阅读(199) 评论(0) 推荐(0) 编辑