摘要: 牛客134 F 题目大意: 给一个字符串,求的是这个字符串的的总价值,这个总价值的求法是,这个字符串中所有回文连续子字符串的价值总和,这个回文子字符串的价值总和就是这个子字符串的长度的平方 (这位更是重量级:(https://anoth3r.top/nkwk134/)) code #include< 阅读全文
posted @ 2026-03-09 21:22 Time_q 阅读(13) 评论(0) 推荐(0)
摘要: 解法1 class Solution{ bool is_covered(unordered_map<int,int>&cnt_s,unordered_map<int,int>&cnt_t){ for(int i='A';i<='Z';i++){ if(cnt_s[i]<cnt_t[i])return 阅读全文
posted @ 2026-03-05 19:20 Time_q 阅读(18) 评论(0) 推荐(0)
摘要: 原题 (https://leetcode.cn/problems/minimum-size-subarray-in-infinite-array/) 原题代码 class Solution { public: int minSizeSubarray(vector<int>& nums, int ta 阅读全文
posted @ 2026-03-05 17:25 Time_q 阅读(20) 评论(0) 推荐(0)
摘要: 原题在此处 解题思路 这道题的原题大致意思可以看上面链接,有一种做法是逆向思维,也就是,只能从首部或者尾部取一个数字,那么剩下的部分肯定是连续的,假设数组长度为n,要取的数字的个数为k,也就是求数组中 n-k个连续子数组的最小值,用总和减去最小值就可以得到最终的答案 原题逆向思维解法代码 class 阅读全文
posted @ 2026-03-04 23:58 Time_q 阅读(16) 评论(0) 推荐(0)
摘要: include<bits/stdc++.h> using namespace std; template int Partition(T a[],int low,int height){ T pivot=a[low];//这个要用T,因为你不知道这个是什么类型的数据 while(low<height 阅读全文
posted @ 2026-03-04 21:07 Time_q 阅读(12) 评论(0) 推荐(0)
摘要: 快速排序优化:随机化基准值避免复杂度退化 为什么需要随机化选取基准值? 选第一个元素作为基准:升序/降序数组会让快排复杂度退化为 O(n²) 选中间元素作为基准:存在 "Anti-QuickSort" 恶意数据,同样会退化为 O(n²) 随机化基准:从根本上避免被构造的数据 Hack,保证平均 O( 阅读全文
posted @ 2026-03-04 20:40 Time_q 阅读(21) 评论(0) 推荐(0)