• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
MKT-porter
博客园    首页    新随笔    联系   管理    订阅  订阅

随笔分类 -  0_0_1刷题

189 轮转数组

摘要:class Solution { public: // 通过1 time 0ms 100% space 30.mb 5% 自己 内存大 void rotate1(vector<int>& nums, int k) { // 1 余数 2 是否大于边界 // 10 6 16=6 12-10=2 cou 阅读全文
posted @ 2025-10-16 05:02 MKT-porter 阅读(1) 评论(0) 推荐(0)
合并区间

摘要:塞入map后,【1,4】被合并了,只剩下一个了。导致后续跳过了 class Solution { public: // 失败 1 思路错 不应该和上一个比较 而是和上一次合并的结果比较 vector<vector<int>> merge1(vector<vector<int>>& intervals 阅读全文
posted @ 2025-10-12 16:37 MKT-porter 阅读(3) 评论(0) 推荐(0)
53最大子数组和 动态规划和分制

摘要:class Solution { public: // 时间不通过 int maxSubArray_2(vector<int>& nums) { int tager_max=nums[0]; int left=0; // sum_[i] map<int,int> sum_i; // 和 索引 由于 阅读全文
posted @ 2025-10-11 01:21 MKT-porter 阅读(2) 评论(0) 推荐(0)
reLeetCode 热题 100- 76 最小覆盖串

摘要:自己 滑动窗 class Solution { public: // 自己第一个 5% 时间满 内存64% 动态滑动窗 string minWindow1(string s, string t) { if(s.size()<t.size()) {return "";} vector<int> t_v 阅读全文
posted @ 2025-10-08 23:24 MKT-porter 阅读(3) 评论(0) 推荐(0)
reLeetCode 热题 100- 239. 滑动窗口最大值 队列

摘要:队列记录最大值集合 方法一1 枚举 速度嘛 n*k 方法2 map 记录频次 通过速度慢 方法3 队列记录当前最大值 最快 class Solution { public: vector<int> maxSlidingWindow(vector<int>& nums, int k) { vector 阅读全文
posted @ 2025-10-08 20:00 MKT-porter 阅读(4) 评论(0) 推荐(0)
reLeetCode 热题 100- 无重复字符的最长子串

摘要:class Solution { public: int lengthOfLongestSubstring(string s) { unordered_set<char> set_charlist; int last=0; int max_=0; for(int i=0;i<s.size();i++ 阅读全文
posted @ 2025-10-02 17:50 MKT-porter 阅读(5) 评论(0) 推荐(0)
reLeetCode 热题 100- 42 接雨水

摘要:class Solution { public: /* 关键 左边界 height[zuo]>height[zuo+1] 右边界 1 是否比height[you]》height[zuo] break; 2 不是最后一个 height[you]>height[you-1] && height[you] 阅读全文
posted @ 2025-09-28 17:30 MKT-porter 阅读(8) 评论(0) 推荐(0)
reLeetCode 热题 100- 15. 三数之和

摘要:1 排序 2 双指针 位置卡死逐步对着移动 左右2个指针 3 while 跳过重复的数 双指针 class Solution { public: vector<vector<int>> my_test1(vector<int>& nums) { std::set<int> index_set; st 阅读全文
posted @ 2025-09-20 02:01 MKT-porter 阅读(3) 评论(0) 推荐(0)
reLeetCode 热题 100-11 盛最多的谁

摘要:1 bu 不合格答案 暴力 // 时间超时 int my_1(vector<int>& height){ // x * hign_min int max_=0; for(int i=0; i<height.size()-1;i++){ for(int j=i+1; j<height.size();j 阅读全文
posted @ 2025-09-17 13:25 MKT-porter 阅读(5) 评论(0) 推荐(0)
reLeetCode 热题 100-1 指针283. 移动零

摘要:class Solution { public: void moveZeroes(vector<int>& nums) { // int cout_=0; // for(int i =0; i<nums.size();i++){ // if(nums[i]==0){ // cout_++; // } 阅读全文
posted @ 2025-09-15 18:46 MKT-porter 阅读(4) 评论(0) 推荐(0)
reLeetCode 热题 100-1 两数之和-扩展3 单向和双向链表实现

摘要:1 阅读全文
posted @ 2025-09-15 12:33 MKT-porter 阅读(4) 评论(0) 推荐(0)
reLeetCode 热题 100-1 两数之和-扩展2 map实现

摘要:1使用例子 #include <iostream> #include <map> #include <string> int main() { // 创建一个从string到int的map std::map<std::string, int> ageMap; // 插入元素 ageMap["Alic 阅读全文
posted @ 2025-09-15 12:33 MKT-porter 阅读(3) 评论(0) 推荐(0)
reLeetCode 热题 100-3 最长连续序列扩展 排序算法

摘要:1 左右值概念 2 结构体定义 3 const作用 给一个这样的例子 ​​const成员函数​​:保证不会修改对象的状态,可以在 const对象上调用。 4排序算法 选择排序 #include <iostream> #include <vector> void selectionSort(std:: 阅读全文
posted @ 2025-09-12 12:05 MKT-porter 阅读(2) 评论(0) 推荐(0)
reLeetCode 热题 100-3 最长连续序列

摘要:1 不需要排序算法。使用表插入代替了排序,无序,只需要检查是否存在数据。 自己方法1 不合格 排序算法 快速排序 时间O(n2) class Solution { public: int longestConsecutive(vector<int>& nums) { if (nums.empty() 阅读全文
posted @ 2025-09-11 20:58 MKT-porter 阅读(3) 评论(0) 推荐(0)
reLeetCode 热题 100-2 字母异位词分组 扩展

摘要:1 字符排序 #include <iostream> #include <algorithm> // for std::sort #include <string> int main() { std::string str = "programming"; // 对字符串中的字符进行排序 std:: 阅读全文
posted @ 2025-09-10 23:54 MKT-porter 阅读(2) 评论(0) 推荐(0)
reLeetCode 热题 100-2 字母异位词分组

摘要:自己的答案 class Solution { public: std::map<char,int> GetStringMap(string msg_){ std::map<char,int> charMap; for(char c : msg_) { charMap[c]++; } // std:: 阅读全文
posted @ 2025-09-10 23:52 MKT-porter 阅读(1) 评论(0) 推荐(0)
reLeetCode 热题 100-1 两数之和-扩展1 unordered_map实现

摘要:1 C++ unordered_map 实现 unordered_map是 C++ STL 中的关联容器,它存储键值对,使用哈希表实现,提供平均 O(1) 时间复杂度的查找、插入和删除操作。 1基本用法 #include <iostream> #include <unordered_map> #in 阅读全文
posted @ 2025-09-09 17:07 MKT-porter 阅读(3) 评论(0) 推荐(0)
reLeetCode 热题 100-1 两数之和-哈希表

摘要:1暴力拆解 扩展 2.1 unordered_map #include <iostream> #include <unordered_map> #include <string> int main() { // 创建 unordered_map std::unordered_map<std::str 阅读全文
posted @ 2025-09-09 17:03 MKT-porter 阅读(5) 评论(0) 推荐(0)

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3