
数据结构与算法
江上渔者21号
这个作者很懒,什么都没留下…
展开
-
时间复杂度学习
1算法分析(1)-循环的时间复杂度https://www.cnblogs.com/aademeng/articles/7401244.html算法导论------递归算法的时间复杂度求解https://blog.youkuaiyun.com/so_geili/article/details/53444816...原创 2019-12-21 15:51:09 · 240 阅读 · 0 评论 -
Two sum 数组中两个数字的和为指定的target值
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same el...原创 2018-04-16 21:16:03 · 470 阅读 · 0 评论 -
数字是否回文
Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.Example 3:I...原创 2018-04-17 00:31:14 · 143 阅读 · 0 评论 -
三个数的和等于target值
Given array nums = [-1, 0, 1, 2, -1, -4],A solution set is:[ [-1, 0, 1], [-1, -1, 2]]这道题让我们求三数之和,比之前那道Two Sum要复杂一些,博主考虑过先fix一个数,然后另外两个数使用Two Sum那种HashMap的解法,但是会有重复结果出现,就算使用set来去除重复也不行,会T...原创 2018-04-22 02:10:00 · 1586 阅读 · 0 评论 -
最长回文字串
class Solution {public: string longestPalindrome(string s) { int maxlen=0; int start=0; int n=s.size(); string s2=s; reverse(s2.begin(),s2.end()); ...原创 2018-04-13 00:02:57 · 149 阅读 · 0 评论 -
栈的问题
3.3 设计包含min函数的栈题: 设计一个栈,使得push、pop以及min(获取栈中最小元素)能够在常数时间内完成。分析: 刚开始很容易想到一个方法,那就是额外建立一个最小二叉堆保存所有元素,这样每次获取最小元素只需要 O(1) 的时间。但是这样的话,为了建最小堆 push 和 pop 操作就需要 O(lgn) 的时间了(假定栈中元素个数为n),不符合题目的要求。解1:辅助栈方法...转载 2019-01-03 16:26:32 · 231 阅读 · 0 评论 -
B树与B+树的区别
如图所示,区别有以下两点:1. B+树中只有叶子节点会带有指向记录的指针(ROWID),而B树则所有节点都带有,在内部节点出现的索引项不会再出现在叶子节点中。2. B+树中所有叶子节点都是通过指针连接在一起,而B树不会。 B+树的优点:1. 非叶子节点不会带上ROWID,这样,一个块中可以容纳更多的索引项,一是可以降低树的高度。二是一个内部节点可以定位更多的叶子节点。...转载 2019-01-27 08:48:51 · 901 阅读 · 0 评论