导航

2014年10月22日

摘要: 给出的是一个字符串数组,然后去求这些字符串的最长公共前缀,挺有意思的一道题目。public class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length==0||strs[0... 阅读全文

posted @ 2014-10-22 23:06 八竿子打不着 阅读(138) 评论(0) 推荐(0)

摘要: 将图片旋转90°,实际上就是在操作数组,感觉实际中canvas可以用到。public class Solution { public void rotate(int[][] matrix) { if (matrix.length == 1) { return... 阅读全文

posted @ 2014-10-22 22:47 八竿子打不着 阅读(90) 评论(0) 推荐(0)

摘要: 这个题目也比较有意思,让自己写代码实现幂运算,这里最大的问题是时间复杂度,负责的话编程实现非常容易。贴出代码,注意其中对奇偶数的判断。public class Solution { public double pow(double x, int n) { if(x==1){ ... 阅读全文

posted @ 2014-10-22 00:18 八竿子打不着 阅读(139) 评论(0) 推荐(0)