摘要: 两个数组的交集 链接349. 两个数组的交集 - 力扣(LeetCode) class Solution { public: vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { unordered_set<int> r 阅读全文
posted @ 2022-11-08 00:00 凱風快晴 阅读(22) 评论(0) 推荐(0)
摘要: 有效的字母异位词 题目链接242. 有效的字母异位词 - 力扣(LeetCode) class Solution { public: bool isAnagram(string s, string t) { int record[26] = {0}; for(int i = 0; i < s.siz 阅读全文
posted @ 2022-11-06 23:15 凱風快晴 阅读(18) 评论(0) 推荐(0)
摘要: 链表相交 题目链接面试题 02.07. 链表相交 - 力扣(LeetCode) class Solution { public: ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { ListNode* curA = he 阅读全文
posted @ 2022-11-04 23:25 凱風快晴 阅读(16) 评论(0) 推荐(0)
摘要: 反转链表 题目链接206. 反转链表 - 力扣(LeetCode) class Solution { public: ListNode* reverseList(ListNode* head) { ListNode* temp; ListNode* cur = head; ListNode* pre 阅读全文
posted @ 2022-11-04 00:13 凱風快晴 阅读(26) 评论(0) 推荐(0)
摘要: 移除链表元素 题目链接203. 移除链表元素 - 力扣(LeetCode) class Solution { public: ListNode* removeElements(ListNode* head, int val) { ListNode* varHead = new ListNode(0) 阅读全文
posted @ 2022-11-03 00:26 凱風快晴 阅读(27) 评论(0) 推荐(0)
摘要: 长度最小的子数组 题目链接209. 长度最小的子数组 - 力扣(LeetCode) 看似很简单。看完滑动窗口法的时候觉得很容易理解,时间复杂度O(n)的推导也理解。无非就是两个指针,因为题目要求子串必连续。 所以一个循环内嵌套一个慢指针,剔除大于目标值的部分 写的时候就漏了很多细节。第一次提交,条件 阅读全文
posted @ 2022-11-01 23:10 凱風快晴 阅读(19) 评论(0) 推荐(0)
摘要: 移除元素 题目链接 27. 移除元素 - 力扣(LeetCode) class Solution { public: int removeElement(vector<int>& nums, int val) { int slotIndex = 0; for(int fastIndex = 0; f 阅读全文
posted @ 2022-10-31 23:37 凱風快晴 阅读(23) 评论(0) 推荐(0)
摘要: 二分查找基础: 二分查找 题目链接 Loading Question... - 力扣(LeetCode) 最开始的题解: class Solution { public: int search(vector<int>& nums, int target) { int left = 0 ; int r 阅读全文
posted @ 2022-10-30 23:48 凱風快晴 阅读(23) 评论(0) 推荐(0)