摘要:
//用string的每一个元素开始往后查找直到出现重复字母为止,求出每一个结果返回最大值 时间复杂度O(n2) int lengthOfLongestSubstring(string s) { int res = 0; for(auto i = s.begin(); i != s.end(); ++ 阅读全文
摘要:
看背包问题 复习了下leetcode 的72 动态规划 class Solution {public: int minDistance(string word1, string word2) { int n1 = word1.length(); int n2 = word2.length(); ve 阅读全文
摘要:
用递归思想解决 f(n) = f(n - 1) * 2 + 1; python: def move(n, a, b, c): if n == 1: print('move', a, '-->', c) else: move(n - 1, a, c, b) print('move', a, '-->' 阅读全文
摘要:
leetcode 217. Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value 阅读全文
摘要:
leetcode 72. Edit Distance space = O(mn)解法 class Solution {public: int minDistance(string word1, string word2) { int m = word1.length(), n = word2.len 阅读全文