上一页 1 2 3 4 5 6 7 8 ··· 11 下一页
最简单的可以采用暴力解法,时间复杂度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(82) Comments(0) Diggs(0)
注意特殊情况 Read More
posted @ 2017-04-21 11:44 chengcy Views(117) Comments(0) Diggs(0)
方法一:使用基本的遍历算法 方法二:使用KMP算法 Read More
posted @ 2017-04-21 11:03 chengcy Views(113) Comments(0) Diggs(0)
class Solution { public: bool isPalindrome(string s) { transform(s.begin(), s.end(), s.begin(), ::tolower); int lt = 0, rt = s.size()-1; while(lt = 0) { ... Read More
posted @ 2017-04-20 21:51 chengcy Views(100) Comments(0) Diggs(0)
方法:使用递归的思想 更简单的递归写法: Read More
posted @ 2017-04-19 23:03 chengcy Views(129) Comments(0) Diggs(0)
方法:采用递归的方式 Read More
posted @ 2017-04-19 22:24 chengcy Views(97) Comments(0) Diggs(0)
方法:递归的方式,这里使用一个变量记录cur保存遍历过程中的变量,类似于前序遍历 同样,对应path sum III问题,使用前序遍历的方式 Read More
posted @ 2017-04-18 21:19 chengcy Views(139) Comments(0) Diggs(0)
方法:采用递归的方法,方法与maxdepth类似 Read More
posted @ 2017-04-18 19:52 chengcy Views(98) Comments(0) Diggs(0)
方法一:基于递归的方式 方法二:使用递归的方式 Maximum depth of binary tree方法和minimum相同 方法一:递归 方法二:迭代: Read More
posted @ 2017-04-17 21:39 chengcy Views(174) Comments(0) Diggs(0)
上一页 1 2 3 4 5 6 7 8 ··· 11 下一页