Leetcode刷题
TwinkleZhao
这个作者很懒,什么都没留下…
展开
-
[Leetcode] 56. Merge Interval (Python)
@[TOC]([Leetcode] 56. Merge Interval (Python) - Medium)题目大意 - 合并区间Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the i原创 2020-11-19 02:47:39 · 249 阅读 · 0 评论 -
[Leetcode] 858. Mirror Reflection (Python)
@[TOC]([Leetcode] 858. Mirror Reflection (Python))题目大意There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2.The square room has原创 2020-11-17 17:54:42 · 253 阅读 · 2 评论 -
[Leetcode] 845. Longest Mountain in Array (Python)
@[TOC]([Leetcode] 845. Longest Mountain in Array (Python))题目大意先up再down找序列中最长山脉的长度。Let’s call any (contiguous) subarray B (of A) a mountain if the following properties hold:B.length >= 3There exists some 0 < i < B.length - 1 such that B[0] <原创 2020-11-16 21:42:59 · 202 阅读 · 1 评论 -
[Leetcode][Python][DFS] 938. Range Sum of BST
[Leetcode][Python][DFS] 938. Range Sum of BST题目大意题目解析代码题目大意给定root二叉搜索树的节点,返回范围为[low, high] 的所有节点的值之和。例题:输入: root = [10,5,15,3,7,null,18],low = 7,high = 15输出: 7+10+15 = 32题目解析第一点:利用BTS性质,node.left.val < node.val < node.right.val第二点:DFS第三点:递归原创 2020-11-15 17:55:53 · 140 阅读 · 0 评论 -
[Leetcode][Python][Dynamic Programming] Longest Increasing Subsequence系列 300, 673
[Leetcode][Python][Dynamic Programming] Longest Increasing Subsequence系列 300, 673300. Longest Increasing Subsequence题目大意解法1:DP代码解法2:DP + Binary Search代码673. Number of Longest Increasing Subsequence解法:DP代码300. Longest Increasing Subsequence题目大意求解给定数组的最长递原创 2020-10-30 21:18:13 · 117 阅读 · 0 评论 -
[Leetcode][Python] Stone Game I,IV总结
[Leetcode][Python] Stone Game I,II,III,IV总结Stone Game I代码Stone Game IV代码Stone Game I题目链接:https://leetcode.com/problems/stone-game/题目解析:DP问题MIN-MAX会超时。dp[i][j]: 从第i个石头到第 j 即 (i+l-1)个石头之间最大的对手得分差。Alex取piles[i]时,Lee也保持最佳状态从[ i+1, j ]中取值Alex取piles[j]时,L原创 2020-10-25 18:38:58 · 298 阅读 · 0 评论 -
[Leetcode][Python] Best Time to Buy and Sell Stock I,II,III,IV总结
[Leetcode][Python] Best Time to Buy and Sell Stock I,II,III,IV121. Best Time to Buy and Sell Stock I题目大意代码122. Best Time to Buy and Sell Stock II题目大意代码123. Best Time to Buy and Sell Stock III题目大意代码188. Best Time to Buy and Sell Stock IV题目大意代码121. Best Tim原创 2020-10-18 17:54:21 · 214 阅读 · 2 评论 -
[Leetcode][Python] 148. Sort List 排序链表
[Leetcode][Python] 148. Sort List 排序链表题目大意解题思路 1:归并排序代码解题思路 2:借助列表和sort()代码题目大意题目连接:Given the head of a linked list, return the list after sorting it in ascending order.Follow up: Can you sort the linked list in O(n logn) time and O(1) memory (i.e. con原创 2020-10-13 21:39:47 · 279 阅读 · 0 评论