摘要: 打卡第七十八天 2道简单题+1道中等题 题目: 思路: 代码: class Solution { public: ListNode* modifiedList(vector<int>& nums, ListNode* head) { unordered_set<int> st(nums.begin( 阅读全文
posted @ 2026-01-25 22:52 Wy0518 阅读(3) 评论(0) 推荐(0)
摘要: 打卡第七十七天 2道中等题 题目: 思路: 代码: class Solution { public: vector<ListNode*> splitListToParts(ListNode* head, int k) { int n = 0; ListNode *temp = head; while 阅读全文
posted @ 2026-01-25 22:30 Wy0518 阅读(3) 评论(0) 推荐(0)
摘要: 打卡第七十六天 1道简单题+2道中等题 题目: 思路:遍历链表并维护上一个和第一个临界点 代码: class Solution { public: vector<int> nodesBetweenCriticalPoints(ListNode* head) { if (!head || !head- 阅读全文
posted @ 2026-01-22 22:58 Wy0518 阅读(1) 评论(0) 推荐(0)
摘要: 打卡第七十五天 2道中等题 并查集模板 题目: 思路:并查集+哈希 代码: class UnionFind { vector<int> fa; vector<int> sz; public: int cc; UnionFind(int n) : fa(n), sz(n, 0), cc(n) { io 阅读全文
posted @ 2026-01-21 22:51 Wy0518 阅读(1) 评论(0) 推荐(0)
摘要: 打卡第七十四天 1道中等题 题目: 思路:并查集 代码: class Solution { public: vector<int> parent; // 存储每个节点的父节点 vector<int> findRedundantConnection(vector<vector<int>>& edges 阅读全文
posted @ 2026-01-02 23:08 Wy0518 阅读(6) 评论(0) 推荐(0)
摘要: 打卡第七十三天 2道中等题 题目: Trie Tree 的实现: 性质: 代码: class Trie { private: bool isEnd; Trie* next[26]; public: Trie() { isEnd = false; memset(next, 0, sizeof(next 阅读全文
posted @ 2026-01-01 23:38 Wy0518 阅读(3) 评论(0) 推荐(0)
摘要: 打卡第七十二天 2道中等题 题目: 思路:贪心 优先使用数量多的字符,确保不连续出现三个相同字符 比较 a 和 b 的数量,根据差值决定添加模式 始终保持两种字符的平衡,避免一种字符过多导致无法避免连续三个相同字符 代码: class Solution { public: string strWit 阅读全文
posted @ 2025-12-31 22:33 Wy0518 阅读(7) 评论(0) 推荐(0)
摘要: 打卡第七十一天 2道中等题 题目: 思路: 代码: class Solution { public: vector<int> resultsArray(vector<vector<int>>& queries, int k) { vector<int> ans(queries.size(), -1) 阅读全文
posted @ 2025-12-30 22:29 Wy0518 阅读(4) 评论(0) 推荐(0)
摘要: 打卡第七十天 2道中等题 题目: 思路: 代码: class Solution { public: int minStoneSum(vector<int>& piles, int k) { priority_queue<int> pq(piles.begin(), piles.end());// 创 阅读全文
posted @ 2025-12-29 22:55 Wy0518 阅读(6) 评论(0) 推荐(0)
摘要: 打卡第六十九天 2道中等题 题目: 思路: 代码: class SmallestInfiniteSet { public: SmallestInfiniteSet() {} int popSmallest() { if (!s.empty()) { int ans = *s.begin(); // 阅读全文
posted @ 2025-12-28 23:16 Wy0518 阅读(5) 评论(0) 推荐(0)