由于水平原因,博客大部分内容摘抄于网络,如有错误或者侵权请指出,本人将尽快修改

随笔分类 -  leetcode题目解析

1
部分leetcode的题目解析
摘要:实现一个算法,找出整数数组中的下一个排列。即字典序比当前排列大的最小排列。 示例: 输入:[1,2,3] 输出:[1,3,2] 输入:[3,2,1] 输出:[1,2,3] 输入:[1,1,5] 输出:[1,5,1] 说明: 整数数组中的元素各不相同。 给定数组始终有效,即始终存在下一个排列。 解题思 阅读全文
posted @ 2024-10-19 23:40 小纸条 阅读(19) 评论(0) 推荐(0) 编辑
摘要:121题 给定一个数组prices,其中prices[i]是一支给定股票第i天的价格。设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。但是,你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 示例 输入:prices = [7,1,5,3,6,4 阅读全文
posted @ 2024-09-08 10:25 小纸条 阅读(37) 评论(0) 推荐(0) 编辑
摘要:一、滑动窗口伪代码二、滑动窗口经典题目01.643. 子数组最大平均数 I02.209. 长度最小的子数组03.3. 无重复字符的最长子串04.76. 最小覆盖子串(难)05.485. 最大连续 1 的个数06.487. 最大连续1的个数 II07.1004. 最大连续1的个数 III08.1151 阅读全文
posted @ 2021-11-03 21:29 小纸条 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: 题目问阶乘的结果有几个零,如果用笨方法求出阶乘然后再算 0 的个数会超出时间限制。 然后我们观察一下,5 的阶乘结果是 120, 阅读全文
posted @ 2019-06-06 14:10 小纸条 阅读(91) 评论(0) 推荐(0) 编辑
摘要:Shuffle a set of numbers without duplicates. Example: 阅读全文
posted @ 2019-06-01 15:34 小纸条 阅读(114) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique q 阅读全文
posted @ 2019-06-01 14:43 小纸条 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the s 阅读全文
posted @ 2019-06-01 11:23 小纸条 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 阅读全文
posted @ 2019-05-31 19:21 小纸条 阅读(105) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list, determine if it is a palindrome. Example 1: Example 2: Follow up:Could you do it in O(n) time and O(1) space? (1)定义快慢指针得到链 阅读全文
posted @ 2019-05-31 19:09 小纸条 阅读(78) 评论(0) 推荐(0) 编辑
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2019-05-29 17:46 小纸条 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2: Input: nums = [1], k = 1 Output: [1] 这个题目更加像是一道语法题目。。。 阅读全文
posted @ 2019-05-28 16:48 小纸条 阅读(130) 评论(0) 推荐(0) 编辑
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文
posted @ 2019-05-24 16:52 小纸条 阅读(151) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 参考链接:https://blog.csdn.net/qq_36172443/article/detail 阅读全文
posted @ 2019-01-02 15:19 小纸条 阅读(168) 评论(0) 推荐(0) 编辑
摘要:这是一题不太明显的动态规划,主要考察的应该是深度优先搜索。 if (set.contains(str)) { list.add(str); dfs(s.substring(i, s.length()), set); list.pollLast(); } if (set.contains(str)) 阅读全文
posted @ 2018-12-21 20:45 小纸条 阅读(176) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://leetcode-cn.com/problems/word-break/ 参考链接:https://blog.csdn.net/c_flybird/article/details/80703494 http://www.cnblogs.com/springfor/p/387 阅读全文
posted @ 2018-12-21 20:34 小纸条 阅读(189) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://leetcode-cn.com/problems/palindrome-partitioning-ii/description/ 参考链接:https://blog.csdn.net/jingsuwen1/article/details/51934277 dp[i]存放[0 阅读全文
posted @ 2018-12-19 17:30 小纸条 阅读(269) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://leetcode-cn.com/problems/distinct-subsequences/description/ 参考链接:https://www.cnblogs.com/springfor/p/3896152.html http://blog.csdn.net/ab 阅读全文
posted @ 2018-12-17 11:47 小纸条 阅读(280) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://leetcode-cn.com/problems/interleaving-string/description/ 参考链接:https://blog.csdn.net/u011095253/article/details/9248073 https://www.cnblo 阅读全文
posted @ 2018-12-14 20:20 小纸条 阅读(194) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://leetcode-cn.com/problems/decode-ways/description/ 参考:https://www.jianshu.com/p/5a604070cd11 题目大意:将一串数字,编码成A-Z的字符串。因为12-->L,或者12-->AB。所有12 阅读全文
posted @ 2018-12-12 18:37 小纸条 阅读(357) 评论(0) 推荐(0) 编辑
摘要:这是前面150多题目的leetcode题目解析 阅读全文
posted @ 2018-12-12 11:54 小纸条 阅读(131) 评论(0) 推荐(0) 编辑

1
点击右上角即可分享
微信分享提示