摘要: ###1. 两两比较 把当前最长公共前缀与每一个字符串比较,并进行更新减小 class Solution { public: string longestCommonPrefix(vector<string>& strs) { if (!strs.size()) { return ""; } str 阅读全文
posted @ 2022-05-16 16:52 失控D大白兔 阅读(38) 评论(0) 推荐(0)
摘要: 给定一个字符串s,请你找出其中不含有重复字符的最长子串的长度。 ###1. 暴力双循环 双指针动态维持更新一个无重复子串,每移动一次右指针,判断新加入字符是否在子串中存在 若存在,则找出其在子串中位置,并更新左指针位置,时间复杂度O(n2) class Solution { public: int 阅读全文
posted @ 2022-05-16 09:46 失控D大白兔 阅读(43) 评论(0) 推荐(0)
摘要: ###一. 串的查找 ####1. [最长回文子串(中心扩散/动态规划)](https://www.cnblogs.com/929code/p/16250463.html) ####2. [最长无重复子串(双指针)](https://www.cnblogs.com/929code/p/1627584 阅读全文
posted @ 2022-05-16 08:27 失控D大白兔 阅读(23) 评论(0) 推荐(0)
摘要: 树一般使用递归方式来拆分成子问题 ####1. 合并二叉树 class Solution { public: TreeNode* mergeTrees(TreeNode* root1, TreeNode* root2) { if(!root1&&!root2) return nullptr; if( 阅读全文
posted @ 2022-05-16 08:15 失控D大白兔 阅读(33) 评论(0) 推荐(0)