图
...
代码随想录算法训练营第十一天-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
CDay10C++49
常用数据结构工作中,最常用的数据结构有:数组,链表,栈,队列,哈希表和二叉搜索树。数组我们已经很熟悉了,因此不再赘述。接下来我们分别讨论下链表、栈、队列、哈希表和二叉搜索树。 网站推荐:数据结构与算法可视化Data Structure Visualization (usfca.edu) 链表链表:是用”链”将结点串联起来的数据结构。 结点:是一个对象(在C语言中就是一个结构体)。该对象中有数据域和指针域,数据域顾名思义存放的就是数据,指针域存放的是结点(可以是另一个结点,也可以是自身)的地址 链表的分类:单向链表 单向循环链表 双向链表 双向循环链表 循环链表我们用的一般比较少,但是当处理的数据具有环形结构时,就特别适合用循环链表,比如约瑟夫环问题。接下来我们讨论下最常用单向链表和双向链表。 单链表基本操作 添加 (在某个结点后面添加) O(1) 12newNode->next = curr->next;curr->next = newNode; 删除 (在某个结点后面删除) O(1) 123Node* removed =...