保研机试day3

题单主要是鼠群群友书写的感觉还不错,就先拿这个练练手吧。链接:https://vjudge.net/article/8781 洛谷-P1757

2025年06月03日 · 1 分钟 · 70 字 · ZhaoYang

保研机试day2

题单主要是鼠群群友书写的感觉还不错,就先拿这个练练手吧。链接:https://vjudge.net/article/8781 随手写了道代码随想录: https://kamacoder.com/problempage.php?pid=1046 ...

2025年06月02日 · 2 分钟 · 539 字 · ZhaoYang

保研机试day1

题单主要是鼠群群友书写的感觉还不错,就先拿这个练练手吧。链接:https://vjudge.net/article/8781 洛谷-P5734 文字处理软件 代码: ...

2025年06月01日 · 1 分钟 · 388 字 · ZhaoYang

每日一题06

2023年04月08日 · 0 分钟 · 0 字 · ZhaoYang

每日一题05

每日一题 哈希表 python中defaultdict类的使用: https://blog.nowcoder.net/n/2aef535877a84165b8b7d99032ecbf09 python中Counter类的使用: https://blog.csdn.net/sinat_28576553/article/details/99131954

2023年04月07日 · 1 分钟 · 51 字 · ZhaoYang

每日一题04

每日一题 链表定义 cpp struct ListNode{ int val; ListNode *next; ListNode(int x) : val(x),next(NULL) {} } python class ListNode: def __init__(self, val, next = None): self.val = val self.next = next 移除链表元素 https://leetcode.cn/problems/remove-linked-list-elements/ cpp /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: ListNode* removeElements(ListNode* head, int val) { while(head != NULL && head->val == val){ ListNode* temp = head; head = head-> next; delete temp; } ListNode* cur = head; while(cur != NULL && cur->next != NULL){ if(cur->next->val == val){ ListNode* temp = cur->next; cur->next = cur->next->next; delete temp; }else{ cur = cur->next; } } return head; } }; python ...

2023年04月05日 · 1 分钟 · 225 字 · ZhaoYang

每日一题03

每日一题 滑动窗口 leetcode 209 长度最小的子数组 https://leetcode.cn/problems/minimum-size-subarray-sum/ 代码: cpp class Solution { public: int minSubArrayLen(int target, vector<int>& nums) { int sum = 0; int j = 0; int res = nums.size() + 10; for(int i = 0; i < nums.size(); i++ ){ sum += nums[i]; while(sum >= target ){ res = min(res, i - j + 1); sum -= nums[j++]; } } res = (res == nums.size() + 10 ? 0 : res); return res; } }; python: class Solution: def minSubArrayLen(self, target: int, nums: List[int]) -> int: res = len(nums) + 10 sum = 0 j = 0 for i in range(len(nums)): sum += nums[i] while sum >= target: res = min(res, i - j + 1) sum -= nums[j] j += 1 if res == len(nums) + 10: res = 0 return res leetcode 904 水果成篮 https://leetcode.cn/problems/fruit-into-baskets/ 代码: cpp: class Solution { public: int totalFruit(vector<int>& fruits) { int res = 0; unordered_map<int, int> cnt; int j = 0; for(int i = 0; i < fruits.size(); i++){ cnt[fruits[i]]++; while(cnt.size() > 2){ auto it = cnt.find(fruits[j]); it->second--; if(it->second == 0) cnt.erase(fruits[j]); j++; } res = max(res, i - j + 1); } return res; } }; python ...

2023年04月04日 · 2 分钟 · 930 字 · ZhaoYang