摘要: 151.翻转字符串里的单词 题目链接:https://leetcode.cn/problems/reverse-words-in-a-string/description/ 暴力removeExtraSpaces: void removeExtraSpaces(string& s) { for (i 阅读全文
posted @ 2024-08-17 14:05 kurumaruq 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 344.反转字符串 题目链接:https://leetcode.cn/problems/reverse-string/description/ 我的代码: class Solution { public: void reverseString(vector<char>& s) { for (int 阅读全文
posted @ 2024-08-09 15:03 kurumaruq 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 454.四数相加II 题目链接:https://leetcode.cn/problems/4sum-ii/description/ 我的代码: class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& num 阅读全文
posted @ 2024-08-09 00:27 kurumaruq 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 242.有效的字母异位词 题目链接:https://leetcode.cn/problems/valid-anagram/description/ 我的代码: class Solution { public: bool isAnagram(string s, string t) { if (s.si 阅读全文
posted @ 2024-08-07 15:16 kurumaruq 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 24.两两交换链表中的节点 题目链接:https://leetcode.cn/problems/swap-nodes-in-pairs/description/ 我的代码: /** * Definition for singly-linked list. * struct ListNode { * 阅读全文
posted @ 2024-08-06 01:25 kurumaruq 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 203.移除链表元素 题目链接:https://leetcode.cn/problems/remove-linked-list-elements/description/ 我的代码(分头节点和中间节点两种情况操作): /** * Definition for singly-linked list. 阅读全文
posted @ 2024-08-03 23:48 kurumaruq 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 209.长度最小的子数组 题目链接:https://leetcode.cn/problems/minimum-size-subarray-sum/description/ 我的代码(暴力解法): class Solution { public: int minSubArrayLen(int targ 阅读全文
posted @ 2024-08-02 03:19 kurumaruq 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 704. 二分查找 题目链接:https://leetcode.cn/problems/binary-search/description/ 我的代码: class Solution { public: int search(vector<int> &nums, int target) { int 阅读全文
posted @ 2024-08-01 14:22 kurumaruq 阅读(62) 评论(0) 推荐(0) 编辑