方法:与substring的不同是这里不需要子串连续 或者 Read More
posted @ 2017-04-22 22:57 chengcy Views(203) Comments(0) Diggs(0)
class Solution { public: int longestPalindrome(string s) { unordered_map hashTable; for(int i=0; i::iterator iter; bool flag = false; for(iter = hashTable.begin();... Read More
posted @ 2017-04-22 21:19 chengcy Views(97) Comments(0) Diggs(0)
最简单的可以采用暴力解法,时间复杂度O(n^3),但时间会溢出 方法:使用动态规划的方法 方法二:采用向两边扩展的方法 Read More
posted @ 2017-04-22 20:57 chengcy Views(169) Comments(0) Diggs(0)
class Solution { public: string addBinary(string a, string b) { int n = a.size() > b.size() ? a.size() : b.size(); reverse(a.begin(), a.end()); reverse(b.begin(), b.end())... Read More
posted @ 2017-04-22 16:39 chengcy Views(84) Comments(0) Diggs(0)