代码随想录算法训练营第十三天-239,347,总结
239. 滑动窗口最大值教程【C15【模板】单调队列 滑动窗口最值】 https://www.bilibili.com/video/BV1H5411j7o6/?share_source=copy_web&vd_source=82180e49f17daecf14bb6f246fc29cd0 【单调队列 滑动窗口最大值【基础算法精讲 27】】 https://www.bilibili.com/video/BV1bM411X72E/?share_source=copy_web&vd_source=82180e49f17daecf14bb6f246fc29cd0 【单调队列正式登场!| LeetCode:239. 滑动窗口最大值】 https://www.bilibili.com/video/BV1XS4y1p7qj/?share_source=copy_web&vd_source=82180e49f17daecf14bb6f246fc29cd0 用队列模拟 1234567891011121314151617181920class Solution...
图
...
代码随想录算法训练营第十一天-20,1047,150
20. 有效的括号https://leetcode.cn/problems/valid-parentheses/solutions/2771702/20-you-xiao-de-gua-hao-by-joker-ek4-zsmo C可能的写法,不用STL 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182#include <stdio.h>#include <stdlib.h>#define MaxSize 10000// #define SIZE(a) (sizeof(a) / sizeof(a[0]))typedef char ElemType;typedef struct{ ElemType data[MaxSize]; int top;}...
代码随想录算法训练营第十天-理论基础,232,225
232. 用栈实现队列https://leetcode.cn/problems/implement-queue-using-stacks/solutions/2776991/232-yong-zhan-shi-xian-dui-lie-by-joker-zdgqs 225. 用队列实现栈https://leetcode.cn/problems/implement-stack-using-queues/solutions/2777028/225-yong-dui-lie-shi-xian-zhan-by-joker-qkl4z
代码随想录算法训练营第六天 | 哈希表基础理论,242,349,202,1
242. 有效的字母异位词https://leetcode.cn/problems/valid-anagram/solutions/2775370/242-you-xiao-de-zi-mu-yi-wei-ci-by-joker-20gf 349. 两个数组的交集https://leetcode.cn/problems/intersection-of-two-arrays/solutions/2775403/349-liang-ge-shu-zu-de-jiao-ji-by-joker-bsuh0 202. 快乐数https://leetcode.cn/problems/happy-number/solutions/2776407/202-kuai-le-shu-by-joker-ek4-qq3h 1. 两数之和https://leetcode.cn/problems/two-sum/solutions/2776436/1-liang-shu-zhi-he-by-joker-ek4-8s9q
代码随想录算法训练营第四天 |24, 19, 面试题 02.07. 链表相交, 142
24. 两两交换链表中的节点https://leetcode.cn/problems/swap-nodes-in-pairs/solutions/2773835/24-liang-liang-jiao-huan-lian-biao-zhong-qm81 19. 删除链表的倒数第 N 个结点https://leetcode.cn/problems/remove-nth-node-from-end-of-list/solutions/2773862/19-shan-chu-lian-biao-de-dao-shu-di-n-ge-f4is 面试题 02.07. 链表相交https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/solutions/2773880/mian-shi-ti-0207-lian-biao-xiang-jiao-by-f694 142. 环形链表...
代码随想录算法训练营第三天 |203.移除链表元素, 707.设计链表, 206.反转链表
203. 移除链表元素https://leetcode.cn/problems/remove-linked-list-elements/solutions/2772075/203-yi-chu-lian-biao-yuan-su-by-joker-ek-kyhf 707. 设计链表https://leetcode.cn/problems/design-linked-list/solutions/2772214/707-she-ji-lian-biao-by-joker-ek4-lbig 思路:因为有dummyHead,因此代码就花了许多,不用考虑第一个借点的情况。注意 void addAtIndex(int index, int val)void deleteAtIndex(int index)的时候,找到下标index - 1节点的时候,要用如下代码 12345LinkedNode *curr = _dummyHead;for (int i = -1; i < index - 1; i++){curr = curr->next;} 206....
代码随想录算法训练营day2-977-209-59
977. 有序数组的平方https://leetcode.cn/problems/squares-of-a-sorted-array/solutions/2769976/977-you-xu-shu-zu-de-ping-fang-by-joker-y0b8q 209. 长度最小的子数组题目大意找出一个数组中最短连续的子数组,这个子数组的和要>=s. 解题方法(O(logn)的方法明天更新)解法称之为虫取法,其实就是双指针。其实看到让连续子数组满足一定条件的很多都用了双指针,比如713. 乘积小于 K 的子数组 时间复杂度是O(N),空间复杂度是O(1)。 https://leetcode.cn/problems/minimum-size-subarray-sum/solutions/2771847/209-chang-du-zui-xiao-de-zi-shu-zu-by-jo-k9a8 相关题目推荐(明天看) 904.水果成篮(opens new window) 76.最小覆盖子串(opens new window) 滑动窗口模板转载自:作者: 负雪明烛...
LeetcodeHot100
LeetcodeHot100链表160. 相交链表https://leetcode.cn/problems/intersection-of-two-linked-lists/solutions/2770777/160-xiang-jiao-lian-biao-by-joker-ek4-69ns 206. 反转链表https://leetcode.cn/problems/reverse-linked-list/solutions/2771061/206-fan-zhuan-lian-biao-by-joker-ek4-lm6d 栈20. 有效的括号https://leetcode.cn/problems/valid-parentheses/solutions/2771702/20-you-xiao-de-gua-hao-by-joker-ek4-zsmo
代码随想录算法训练营47期day01第一章数组part01
代码随想录算法训练营47期day01第一章数组part01