llllmz

导航

上一页 1 2 3 4 5 6 7 ··· 35 下一页

2024年9月26日

24. 两两交换链表中的节点

摘要: 感觉自己畏难情绪好严重呀,一点都不想学新东西。 class Solution { public: ListNode* swapPairs(ListNode* head) { if(!head) return nullptr; if(!head->next) return head; ListNode 阅读全文

posted @ 2024-09-26 19:27 神奇的萝卜丝 阅读(14) 评论(0) 推荐(0)

2024年9月24日

206. 反转链表

摘要: class Solution { public: ListNode* reverseList(ListNode* head) { if(!head) return nullptr; ListNode* cur = head->next; if(!cur) return head; head->nex 阅读全文

posted @ 2024-09-24 18:48 神奇的萝卜丝 阅读(10) 评论(0) 推荐(0)

707. 设计链表

摘要: 心要细,这题才能作对。 class MyLinkedList { public: MyLinkedList() :_size(0), _head(new listedNode(0)) {} int get(int index) { if(index < 0 || index >= _size) re 阅读全文

posted @ 2024-09-24 18:42 神奇的萝卜丝 阅读(12) 评论(0) 推荐(0)

2024年9月20日

203. 移除链表元素

摘要: 老题新做 class Solution { public: ListNode* removeElements(ListNode* head, int val) { if(!head) return nullptr; if(head->val != val){ head->next = removeE 阅读全文

posted @ 2024-09-20 22:18 神奇的萝卜丝 阅读(12) 评论(0) 推荐(0)

2024年9月19日

146. LRU 缓存

摘要: \ class LRUCache { public: LRUCache(int capacity) :_capacity(capacity) {} int get(int key) { auto it = _unorderedMap.find(key); if(it != _unorderedMap 阅读全文

posted @ 2024-09-19 17:31 神奇的萝卜丝 阅读(22) 评论(0) 推荐(0)

20. 有效的括号

摘要: 学习了C++ stack的使用 class Solution { public: #include<stack> bool isValid(string s) { stack<char> stk; for(int i = 0; i < s.size(); ++i){ if(s[i] == '(' | 阅读全文

posted @ 2024-09-19 11:16 神奇的萝卜丝 阅读(17) 评论(0) 推荐(0)

2024年9月18日

44. 开发商购买土地

摘要: \ 路长且艰,任重而道远,什么时候才能成长成真正的程序员呢 #include<iostream> #include<vector> #include<climits> using namespace std; int main(){ int n, m; cin >> n >> m; vector<v 阅读全文

posted @ 2024-09-18 23:04 神奇的萝卜丝 阅读(74) 评论(0) 推荐(0)

2024年9月17日

58. 区间和(第九期模拟笔试)

摘要: 中秋节摆了一天,感觉畏难情绪一直困扰着我,要好好调制状态才行。 #include<iostream> #include<vector> using namespace std; int main(){ int n = 0; cin >> n; vector<int> sum(n, 0); for(i 阅读全文

posted @ 2024-09-17 20:49 神奇的萝卜丝 阅读(22) 评论(0) 推荐(0)

2024年9月16日

59. 螺旋矩阵 II

摘要: 不知道一年后会成长成什么样,只感觉好难好难。有好多东西要学,源码也看不懂,项目也不会做。 class Solution { public: vector<vector<int>> generateMatrix(int n) { vector<vector<int>> vec(n, vector<in 阅读全文

posted @ 2024-09-16 22:29 神奇的萝卜丝 阅读(10) 评论(0) 推荐(0)

2024年9月15日

76. 最小覆盖子串

摘要: class Solution { public: map<char, int> maps, mapt; bool isContained(){ for(pair<char, int> elem : mapt){ if(elem.second > maps[elem.first]) return fa 阅读全文

posted @ 2024-09-15 20:36 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 35 下一页