2013年9月8日

scramble string

摘要: 1 class Solution { 2 public: 3 bool isScramble(string s1, string s2) { 4 // Start typing your Java solution below 5 // DO NOT write main() function 6 string m = s1; 7 string n = s2; 8 sort(m.begin(),m.end()); 9 sort(n.begin(),n.end());10 if( m... 阅读全文

posted @ 2013-09-08 13:46 jumping_grass 阅读(158) 评论(0) 推荐(0)

edit distance

摘要: class Solution {public: int minDistance(string word1, string word2) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > f(word1.size()+1, vector(word2.size()+1)); f[0][0] = 0; for(int i = 1; i <= word2.size(); i++) ... 阅读全文

posted @ 2013-09-08 11:19 jumping_grass 阅读(211) 评论(0) 推荐(0)

simplify path

摘要: class Solution {public: string simplifyPath(string path) { // Start typing your C/C++ solution below // DO NOT write int main() function stack s; string str; for(int i = 0; i < path.size(); i++) { if (path[i] == '/') { ... 阅读全文

posted @ 2013-09-08 11:07 jumping_grass 阅读(158) 评论(0) 推荐(0)

pow(x,n)

摘要: 1 class Solution { 2 public: 3 4 double pow(double x, int n) { 5 // Start typing your C/C++ solution below 6 // DO NOT write int main() function 7 if( abs(x-1) == 0 || (abs(x+1) ==0 && n%2 == 0)) return 1.00000; 8 if( abs(x+1) == 0 && n%2 == 1) return -1.00... 阅读全文

posted @ 2013-09-08 10:46 jumping_grass 阅读(137) 评论(0) 推荐(0)

导航