LeetCode刷题记录
LeetCode是著名的刷题网站,专栏会记录一些博主刷题时写下的题解,题解也可以在:[彼得攀的小站](akeeper.space)查看。博主对于所有的算法,尽可能地对运行时间进行了优化,即至少faster than 97.00% of C++ online submission
彼得.攀
就是想开个博客
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 395. Longest Substring with At Least K Repeating Characters(Medium)题解
查阅更多的题解,请点击 Problem 395. Longest Substring with At Least K Repeating Characters(Medium) Find the length of the longest substring T of a given string (consists of lowercase letters only) such that ever...原创 2019-06-30 13:48:12 · 324 阅读 · 0 评论 -
LeetCode 41. First Missing Positive(Hard)
查阅更多的题解,请点击 Problem 41. First Missing Positive(Hard) Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] Output: 3 Example 2: Input: [3,4,-1,1] Outp...原创 2019-06-26 14:29:41 · 174 阅读 · 0 评论 -
LeetCode 140. Word Break II(Hard)
查阅更多的题解,请点击 Problem 140. Word Break II(Hard) Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a val...原创 2019-06-21 12:26:06 · 180 阅读 · 0 评论 -
LeetCode 139 Word Break(Medium)
查阅更多的题解,请点击 Problem 139. Word Break(Medium) Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence o...原创 2019-06-21 12:22:46 · 202 阅读 · 0 评论 -
LeetCode 300. Longest Increasing Subsequence(Medium)
查阅更多的题解,请点击 Problem 300. Longest Increasing Subsequence(Medium) Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 ...原创 2019-06-10 19:02:59 · 154 阅读 · 0 评论 -
LeetCode 42. Trapping Rain Water(Hard)
查看原文,请点击彼得.攀的小站 查阅更多的题解,请点击 Problem 42. Trapping Rain Water(Hard) Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to tra...原创 2019-04-12 09:06:14 · 346 阅读 · 0 评论 -
LeetCode 45. Jump Game II(Hard)
查阅更多的题解,请点击 Problem 45. Jump Game II(Hard) Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump...原创 2019-06-09 00:16:53 · 171 阅读 · 0 评论 -
LeetCode 84. Largest Rectangle in Histogram(hard)
查阅更多的题解,请点击 Solution Stack O(n) time, O(n) space note: 用s[k]代表第k+1个元素 首先观察问题,不能直接得到一个很好的reduce原问题的策略。 确定一个矩形有三要素:左边界、右边界和高(即左右边界及中间部分值最小的元素,称为bar)。“没有smart”的策略,那么按照最朴素的想法求解:选择一个元素作为可能最大矩阵的bar,向左右扩展寻找左...原创 2019-06-09 00:15:09 · 163 阅读 · 0 评论 -
LeetCode 328. Odd Even Linked List(Medium)
查阅更多的题解,请点击 Problem 328. Odd Even Linked List(Medium) Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not...原创 2019-04-21 14:12:52 · 223 阅读 · 0 评论 -
LeetCode 380. Insert Delete GetRandom O(1)(Medium)
查阅更多的题解,请点击 Problem 380. Insert Delete GetRandom O(1)(Medium) Design a data structure that supports all following operations in average O(1) time. insert(val): Inserts an item val to the set if not a...原创 2019-04-17 21:24:17 · 244 阅读 · 0 评论 -
LeetCode 73. Set Matrix Zeroes(Medium)
原文出处,请点击彼得攀的小站 查阅更多的题解,请点击 Problem 73. Set Matrix Zeroes(Medium) Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,...原创 2019-04-10 21:35:11 · 144 阅读 · 0 评论 -
LeetCode 1218. Longest Arithmetic Subsequence of Given Difference 题解
查阅更多的题解,请点击 GitHub传送门 Problem 1218. Longest Arithmetic Subsequence of Given Difference Solution DP, O(n) time 題目是求最长的等差序列,利用dp求解,假设前i个数我们已经得到解,那么加入第i+1个数x,若x-difference在前i个数中存在,那么更新之前候选序列;若不存在,x可以作为一个...原创 2019-10-08 20:19:44 · 414 阅读 · 0 评论
分享