leetcode
July__
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode11 Container With More Water && Leetcode42 Trapping Rain Water
这两个问题的解决方案都是基于头尾指针进行的,知识点在于对数组的处理。Container With More WaterExample:Input: [1,8,6,2,5,4,8,3,7]Output: 49解法1:从左到右遍历数组,记录最大的数字作为maxHeight(i处的高度),同时遍历i后的每一个数字,不断更新最大容量值,这种情况下的时间复杂度达到了O(n^2);...原创 2019-05-28 21:06:07 · 235 阅读 · 0 评论 -
Leetcode698 Partition to K Equal Sum Subsets
问题描述:判断数组中的数是否可以分为和相等的k组数Example:Input: nums = [4, 3, 2, 3, 5, 2, 1], k = 4Output: TrueExplanation: It's possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums.第一个思路是...原创 2019-05-28 22:50:01 · 177 阅读 · 0 评论 -
Leetcode48 Rotate Image
描述:一个n*n的矩阵,将其顺时针转90°(不允许申请额外的矩阵)Example: Given input matrix = [ [1,2,3], [4,5,6], [7,8,9]],rotate the input matrix in-place such that it becomes:[ [7,4,1], [8,5,2], [9,6,3]]...原创 2019-06-01 22:27:36 · 263 阅读 · 0 评论 -
Leetcode 2 Add Two Numbers
题目描述: 使用链表模拟进位加法,两个链表相加,链表顺序为数字低位到高位Examples:Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8Explanation: 342 + 465 = 807.思路:模拟数字加法要考虑的主要就是进位问题需要考虑的几个点是:1 相加之后的...原创 2019-06-01 22:28:52 · 177 阅读 · 0 评论 -
Leetcode227 Basic Calculator II
描述:实现一个计算器,字符串中只包含非负整数,+,-,*,/和空格Example1: Input: "3+2*2" Output: 7Example2: Input: " 3/2 " Output: 1这道题相对来说还是比较简单的,不需要考虑括号及其他运算,但是我做的答案还是有一些问题,先贴一个个人觉得比较好的代码class Solution {public: ...原创 2019-05-29 20:20:52 · 245 阅读 · 0 评论 -
leetcode 139 Word Break
描述:一个非空字符串s,包含一系列非空单词的字典序列,判断s是否可由一个或多个电词表中的元素构成Note:The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not contain duplicate wor...原创 2019-06-07 20:38:15 · 218 阅读 · 0 评论 -
Leetcode673 Numbber of longest Increasing Subsequence
描述:求最长公共子序列的数量:example1:Input: [1,3,5,4,7]Output: 2Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7].example 2:Input: [2,2,2,2,2]Output: 5Explanation:...原创 2019-06-03 20:55:05 · 232 阅读 · 0 评论
分享