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

2021年3月3日

Sword 09

摘要: https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/ 队列是先进先出,而栈是后进先出 故用两个栈来模拟队列(类似于负负得正) 出栈的时候一定是从 B 中出去的,如果 B 中有元素,直接出即可(已经经历过两 阅读全文

posted @ 2021-03-03 15:05 FriskyPuppy 阅读(38) 评论(0) 推荐(0) 编辑

Sword 07

摘要: https://leetcode-cn.com/problems/zhong-jian-er-cha-shu-lcof/ 重建二叉树 如果手算的话,先由先序遍历的根节点确立中序遍历中根节点的位置 这样根据中序遍历的性质就可以将二叉树分为两部分,也就将先序遍历的二叉树分为两部分 这时候关于原树的根节点 阅读全文

posted @ 2021-03-03 12:04 FriskyPuppy 阅读(36) 评论(0) 推荐(0) 编辑

Sword 06

摘要: https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/ 从尾到头打印链表,递归做 终止状态是如果当前指针为空的话,就返回一个空链表 否则返回一个比当前规模小一的逆置数组合并上当前元素 主要思想就是将大规模问题分 阅读全文

posted @ 2021-03-03 11:07 FriskyPuppy 阅读(22) 评论(0) 推荐(0) 编辑

2021年3月2日

Sword 05

摘要: https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/ 既然要写就写就地 由空格数我们可以确定最后 s 的长度 如果从前到后覆盖会修改原数据,故从后到前 阅读全文

posted @ 2021-03-02 16:51 FriskyPuppy 阅读(10) 评论(0) 推荐(0) 编辑

Sword 04

摘要: https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/ 数组从上到下递增,从左到右递增,寻找一个值 观察数组,若当前 cur == nums[curi][curj] 比 target 小的时候那么所有比 cur 小 阅读全文

posted @ 2021-03-02 15:32 FriskyPuppy 阅读(20) 评论(0) 推荐(0) 编辑

Sword 03

摘要: https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/submissions/ 长度为n 的数组,且范围为0~n-1的数的若没有重复的话是正好可以排满数组的 题目中说一定会有重复,所以肯定有一个坑是占了两个萝卜的 阅读全文

posted @ 2021-03-02 11:34 FriskyPuppy 阅读(25) 评论(0) 推荐(0) 编辑

Sword 42

摘要: https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/submissions/ 连续子数组的最大和,典型的动态规划问题 说白了就是重复利用结果,将大问题拆成小问题 dp[i] = max(dp[i-1] + nums 阅读全文

posted @ 2021-03-02 10:47 FriskyPuppy 阅读(20) 评论(0) 推荐(0) 编辑

2021年3月1日

Sword 40

摘要: https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof/ 应用快排中的 partition 函数, 如果返回值比 K 大就在前半段寻找第 K 大的值, 如果返回值比 K 小就在后半段寻找第 K-num 大的值(num 是pos 的相对位置) 阅读全文

posted @ 2021-03-01 15:36 FriskyPuppy 阅读(23) 评论(0) 推荐(0) 编辑

2021年2月28日

Sword 50

摘要: https://leetcode-cn.com/problems/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-lcof/ 把出现过得所有字符都放在一个字典中,相当于 Counter 从头遍历若发现 Counter[i] == 1 返回 阅读全文

posted @ 2021-02-28 15:21 FriskyPuppy 阅读(16) 评论(0) 推荐(0) 编辑

Sword 52

摘要: https://leetcode-cn.com/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof/ 若两个链表长度不等,交换成第一个链表长,第二个链表短 让长的链表先走 lenA - lenB 步,这样 curA curB 阅读全文

posted @ 2021-02-28 15:00 FriskyPuppy 阅读(14) 评论(0) 推荐(0) 编辑

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

导航