
数据结构算法
xiaofeilongyu
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
跳表简单实现
跳表的简单实现原创 2023-02-28 10:28:29 · 196 阅读 · 1 评论 -
C++ STL容器迭代器失效
vector 1、插入(push_back)元素。end操作返回的迭代器失效 2、插入(push_back)元素,若发生扩容,即capacity返回值有变化,则需重新加载整个容器,此时begin和end操作返回的迭代器都会失效。 3、删除(erase、pop_back)元素,指向删除点的迭代器失效,后面的元素的迭代器也将失效。 qeque 1、在deque容器首部和尾部插入元素不会使任何迭代器失效; 2、在deque容器首部和尾部删除元素,只会使被删除元素的迭代器失效; 3、在deque容器的其他位置原创 2021-03-11 14:23:16 · 330 阅读 · 0 评论 -
仿函数
仿函数(functor)是通过重载()运算符模拟函数形式的类 仿函数不是函数,是个类 反函数重载了()运算符,使得它可以像函数一样调用 用最少的箭引爆气球 题目链接https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons/ 实例: 输入:points = [[10, 16], [2, 8], [1, 6], [7, 12]] 输出:2 解释:x=6,可以射爆[2, 8]和[1, 6]两个气球,x=11原创 2020-12-25 17:40:45 · 783 阅读 · 0 评论 -
heap构建
#pragma once #include <vector> #include <iostream> using namespace std; enum heapType { MAXHEAP, MINHEAP }; template<typename T> class MyHeap { private: std::vector<T> _vecdate; int _size;//元素数量 int _capacity;//整个堆的大小 heapTyp.转载 2020-11-13 17:07:55 · 189 阅读 · 0 评论 -
二叉树相关操作
节点定义 struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode(int x) :val(x), left(NULL), right(NULL); }; 递归法 //前序遍历 void preorderTraversal(TreeNode* root, vector<int>& result) { if(root == null) return; result.push_b转载 2020-10-27 14:32:41 · 210 阅读 · 0 评论 -
KMP算法
class KMP { public: void getNext(int* next, const string str) { int j = -1; next[0] = j; for (int i = 1; i < str.size(); i++)// 注意i从1开始 { while (j >= 0 && str[i] != str[j+1])// 前后缀不相同了 { j = next[j];// 向前回溯 } if (st.转载 2020-10-22 16:05:40 · 92 阅读 · 0 评论 -
数据结构排序算法
#include <iostream> #include <algorithm> using namespace std; //快速顺序 void swap(int* arr, int index1, int index2) { int temp = arr[index1]; arr[index1] = arr[index2]; ...原创 2018-08-15 09:29:07 · 136 阅读 · 0 评论