随笔分类 -  代码随想录个人笔记

摘要:栈与队列理论基础 栈stack:先进后厨 队列queue:先进先出 STL(C++标准库) STL 栈和队列属于容器适配器(container adapter) 优先队列priority_queue: 默认大根堆,如果是pair<a,b>,默认比较a大小 如果需要比较b大小,且小根堆,可以如下实现 阅读全文
posted @ 2023-09-08 16:44 DaxiaWan 阅读(12) 评论(0) 推荐(0) 编辑
摘要:27. 移除元素 题目链接 快慢指针,最终返回index值为移除元素后的数组末尾元素下标+1. #include<vector> using namespace std; class Solution { public: int removeElement(vector<int>& nums, in 阅读全文
posted @ 2023-09-07 21:34 DaxiaWan 阅读(7) 评论(0) 推荐(0) 编辑
摘要:344. 反转字符串 题目链接 #include<bits/stdc++.h> using namespace std; class Solution { public: void reverseString(vector<char>& s) { int len = s.size(); for(in 阅读全文
posted @ 2023-09-07 21:03 DaxiaWan 阅读(36) 评论(0) 推荐(0) 编辑
摘要:哈希表基础知识 哈希表(Hash table)又称散列表,是根据关键码的值而直接进行访问的数据结构 哈希表一般用来快速查询元素a是否在集合B中,O(1)时间复杂度即可做到,枚举的话则是O(n) 哈希函数hashFunction(x):将输入x映射为哈希表上的索引,之后通过查询索引下标即可快速查询x 阅读全文
posted @ 2023-09-07 10:51 DaxiaWan 阅读(18) 评论(0) 推荐(0) 编辑
摘要:链表相关题目 2023-09-01 707.设计链表-leetcode 题目链接 题目: 关键点: 定义成员变量: private: int _size; Node *_dummyHead; 定义链表节点结构体和构造函数: //定义链表节点结构体 struct Node { int val; Nod 阅读全文
posted @ 2023-09-03 17:07 DaxiaWan 阅读(15) 评论(0) 推荐(0) 编辑
摘要:#二分查找 [题目链接](https://leetcode.cn/problems/binary-search/ "题目链接") 注意:求均值防溢出,left+(right-left)/2等价于(left + right)/2。 ![image](https://img2023.cnblogs.co 阅读全文
posted @ 2023-09-02 11:11 DaxiaWan 阅读(6) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示