摘要: /* 题意:求字符串的最后一个单词(不含空字符的) 解法:从后往前扫,先排除空字符,然后统计*/class Solution {public: int lengthOfLastWord(string s) { int res = 0; int i = s... 阅读全文
posted @ 2015-04-20 21:18 SprayT 阅读(74) 评论(0) 推荐(0) 编辑
摘要: /* 题意:实现pow(x,n)函数 坑: 1>要用矩阵快速幂做 2>n可能为负数 3>n可能去INT_MIN所以需要类型转换*/class Solution {public: double pow(double x, int n) { d... 阅读全文
posted @ 2015-04-20 21:06 SprayT 阅读(107) 评论(0) 推荐(0) 编辑
摘要: /* 题意:将一个矩阵顺时针旋转90度 解法:画个图,4个一组交换,实际交换只需要交换左上角的一个小矩形matrix[n/2][(n+1)/2];*/class Solution {public: void rotate(vector > &matrix) { int... 阅读全文
posted @ 2015-04-20 20:47 SprayT 阅读(75) 评论(0) 推荐(0) 编辑
摘要: /* 题意:给一个集合,求所有的排列 做法:*/class Solution {public: vector >res;int count ; void dfs(int A[],vectornum,int n,int cur){ if(cur == n){//找... 阅读全文
posted @ 2015-04-20 20:08 SprayT 阅读(132) 评论(0) 推荐(0) 编辑