llllmz

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

10 2024 档案

20. 有效的括号
摘要:class Solution { public: bool isValid(string s) { int r1 = 0, r2 = 0, r3 = 0; char temp; stack<char> stk; for(int i = 0; i < s.size(); ++i){ if(s[i] = 阅读全文

posted @ 2024-10-24 22:16 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

225. 用队列实现栈
摘要:class MyStack { public: MyStack() : q1(queue<int>()), q2(queue<int>()) { } void push(int x) { q1.push(x); } int pop() { int ret; if(q1.size() == 1){ r 阅读全文

posted @ 2024-10-23 23:01 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

232. 用栈实现队列
摘要:class MyQueue { public: MyQueue() { } void push(int x) { s1.push(x); } int pop() { int ret; if(!empty()){ if(!s2.empty()){ ret = s2.top(); s2.pop(); r 阅读全文

posted @ 2024-10-22 19:08 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

459. 重复的子字符串
摘要:KMP算法一点都不想回忆了,等找实习的时候再仔细看吧 class Solution { public: bool repeatedSubstringPattern(string s) { if(s.size() <= 1) return false; string temp = "", str = 阅读全文

posted @ 2024-10-21 23:33 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

28. 找出字符串中第一个匹配项的下标
摘要:决定转前端了。先用c++刷题刷着先 class Solution { public: int strStr(string haystack, string needle) { if(haystack.size() < needle.size()) return -1; for(int i = 0; 阅读全文

posted @ 2024-10-19 18:20 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

55. 右旋字符串(第八期模拟笔试)
摘要:#include <iostream> #include <string> using std::cin; using std::cout; using std::endl; using std::string; int main(){ int k; string s; cin >> k; cin 阅读全文

posted @ 2024-10-17 18:44 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

541. 反转字符串 II
摘要:class Solution { public: string reverseStr(string s, int k) { for(int i = 0; i < s.size(); i += 2*k){ if(s.size() - i >= k){ reverse(s, i, i + k -1); 阅读全文

posted @ 2024-10-14 23:05 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

344. 反转字符串
摘要:class Solution { public: void reverseString(vector<char>& s) { int head = 0, tail = s.size() -1; while(head < tail){ char temp = s[head]; s[head] = s[ 阅读全文

posted @ 2024-10-14 22:24 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

18. 四数之和
摘要:class Solution { public: vector<vector<int>> fourSum(vector<int>& nums, int target) { vector<vector<int>> ans; sort(nums.begin(), nums.end()); long su 阅读全文

posted @ 2024-10-13 23:00 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

15. 三数之和
摘要:practise makes perfect! 相信自己的努力不会白费,继续学习吧 class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> ans; sort(num 阅读全文

posted @ 2024-10-12 19:45 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

383. 赎金信
摘要:class Solution { public: bool canConstruct(string ransomNote, string magazine) { unordered_map<char, int> unmapran; unordered_map<char, int> unmapmag; 阅读全文

posted @ 2024-10-10 22:38 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

454. 四数相加 II
摘要:class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) { int ans = 0; unordered_map 阅读全文

posted @ 2024-10-08 18:36 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

1. 两数之和
摘要:class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int> unmap; for(int i = 0; i < nums.size(); ++i){ unma 阅读全文

posted @ 2024-10-07 21:56 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

202. 快乐数
摘要:预计再过半个月就可以写项目了,不知道像我这样的彩笔,能不能驾驭得住项目难度,希望可以随便拿捏。 class Solution { public: bool isHappy(int n) { unordered_set<int> unset; while(1){ int sum = getNextNu 阅读全文

posted @ 2024-10-06 20:49 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

349. 两个数组的交集
摘要:class Solution { public: vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { unordered_set<int> ans_set; unordered_set<int> num1_set(nu 阅读全文

posted @ 2024-10-05 21:03 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

242. 有效的字母异位词
摘要:class Solution { public: bool isAnagram(string s, string t) { if(s.size() != t.size()) return false; for(int i = 0; i < s.size(); ++i) ++maps[s[i]]; f 阅读全文

posted @ 2024-10-04 20:04 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

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