E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Leetcode题解
网格结构的DFS——岛屿系列问题
DFS框架本文参考
leetcode题解
:岛屿类问题的通用解法、DFS遍历框架再次感谢大佬DFS基本结构——树voidtraverse(TreeNoderoot){//判断basecaseif(root=
水墨丹晴
·
2020-07-08 00:06
leetcode
LeetCode题解
之动态规划(longest-palindromic-substring)
longest-palindromic-substringclassSolution{public:/*动态规划求解最长回文串时间复杂度为O(n^2)dp[i][j]为true表示下标i~j的子串是回文串以str="eabcbaf"为例,二维dp表如下eabcbafe1000000a100010b10100c1000b100a10f1当j=4,i=2时,更新left=2,right=4,maxLe
城阙
·
2020-07-07 20:40
算法
c++
刷题
leetcode题解
-Combination Sum系列
这个系列一共有四道题,每道题目之间稍微有些不同,下面通过对比来总结一下,四道题目都可以使用backtracking回溯方法做,当然也可以是使用DP进行求解。首先看第一道:39.CombinationSumGivenasetofcandidatenumbers(C)(withoutduplicates)andatargetnumber(T),findalluniquecombinationsinCw
liuchongee
·
2020-07-07 14:54
leetcode刷题
leetcode题解
-647. Palindromic Substrings && 5. Longest Palindromic Substring
题目:Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Inpu
liuchongee
·
2020-07-07 14:23
leetcode刷题
LeetCode题解
——56. 合并区间
题目相关题目链接LeetCode中国,https://leetcode-cn.com/problems/merge-intervals/。题目描述给出一个区间的集合,请合并所有重叠的区间。示例示例1输入:[[1,3],[2,6],[8,10],[15,18]]输出:[[1,6],[8,10],[15,18]]解释:区间[1,3]和[2,6]重叠,将它们合并为[1,6].示例2输入:[[1,4],[
努力的老周
·
2020-07-07 12:00
OJ题解
#
LeetCode题解
Leetcode题解
-62. Unique Paths & 63. Unique Paths II
Leetcode题解
-62.UniquePaths&63.UniquePathsII62.UniquePathsArobotislocatedatthetop-leftcornerofamxngrid(
hzw2945
·
2020-07-07 10:08
Leetcode
Leetcode题解
-55. Jump Game
Leetcode题解
-55.JumpGameGivenanarrayofnon-negativeintegers,youareinitiallypositionedatthefirstindexofthearray.Eachelementinthearrayrepresentsyourmaximumjumplengthatthatposition.Determineifyouareabletore
hzw2945
·
2020-07-07 10:07
Leetcode
Leetcode题解
-198. House Robber
Leetcode题解
-198.HouseRobberYouareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed
hzw2945
·
2020-07-07 10:36
Leetcode
Leetcode题解
-6. ZigZag Conversion
Leetcode题解
-6.ZigZagConversionThestring"PAYPALISHIRING"iswritteninazigzagpatternonagivennumberofrowslikethis
hzw2945
·
2020-07-07 10:36
Leetcode
Leetcode题解
-617. Merge Two Binary Trees
Leetcode题解
-617.MergeTwoBinaryTreesGiventwobinarytreesandimaginethatwhenyouputoneofthemtocovertheother
hzw2945
·
2020-07-07 10:36
Leetcode
Leetcode题解
-31. Next Permutation
Leetcode题解
-31.NextPermutationImplementnextpermutation,whichrearrangesnumbersintothelexicographicallynextgreaterpermutationofnumbers.Ifsucharrangementisnotpossible
hzw2945
·
2020-07-07 10:36
Leetcode
Leetcode题解
-747. Min Cost Climbing Stairs
Leetcode题解
-747.MinCostClimbingStairsOnastaircase,thei-thstephassomenon-negativecostcost[i]assigned(0indexed
hzw2945
·
2020-07-07 10:36
Leetcode
LeetCode题解
:3. Longest Substring Without Repeating Characters
题目中文翻译如下:找出一个字符串的无重复字母的最长子字符串。例如:"abcabcbb"的无重复字母最长子字符串是"abc","pwwkew"的无重复字母最长子字符串是"wke"思考:动态规划的典型应用,保存当前最长字串和包含当前字母的最长字串,遍历一遍就好,重点考虑一下边界,代码如下:publicintlengthOfLongestSubstring(Strings){HashMapcurSet=
htjovi
·
2020-07-07 09:53
leetcode题解
Leetcode题解
——20. 有效的括号
20.有效的括号题解1:取巧的解法classSolution:defisValid(self,s:str)->bool:while'{}'insor'()'insor'[]'ins:s=s.replace('{}','')s=s.replace('[]','')s=s.replace('()','')returns==''题解2:使用栈step1:初始化栈S。step2:依次处理表达式的每个括号。
子季鹰才
·
2020-07-07 09:33
Leetcode题解
——38. 外观数列
38.外观数列题解:classSolution:defcountAndSay(self,n:int)->str:ifn==1:return'1'new_str=''last_str=self.countAndSay(n-1)#获取上次的报数cur=last_str[0]#当前要统计的字符,初始值为last_str的首字符cur_t=0#当前字符出现的次数foriinlast_str:ifi==cu
子季鹰才
·
2020-07-07 09:32
Leetcode题解
——DFS+染色问题
涉及到的题目:886.可能的二分法785.判断二分图此类题目的关键在于构建图,然后将一条边上两个点着不同的颜色,当着色方案为2种颜色时,即为所说的二分图问题。886.可能的二分法classSolution:defpossibleBipartition(self,N:int,dislikes:List[List[int]])->bool:color={}graph=collections.defau
子季鹰才
·
2020-07-07 09:32
Leetcode题解
——动态规划一网打尽股票买卖问题
股票买卖问题涉及到的题目:121.买卖股票的最佳时机122.买卖股票的最佳时机II309.最佳买卖股票时机含冷冻期714.买卖股票的最佳时机含手续费123.买卖股票的最佳时机III188.买卖股票的最佳时机IV此系列的题目可以用状态机的技巧来解决,实际上就是动态规划的DPtable,具体可参考团灭LeetCode股票买卖问题具体来说,要构建的动态规划数组为dp[i][k][0or1]0int:n=
子季鹰才
·
2020-07-07 09:02
[LeetCode] 025. Reverse Nodes in k-Group (Hard) (C++/Java)
索引:[LeetCode]
Leetcode题解
索引(C++/Java/Python/Sql)Github:https://github.com/illuz/leetcode025.ReverseNodesink-Group
hcbbt
·
2020-07-07 09:23
=====算法相关=====
+Leetcode
+基础算法
Leetcode
题解
[LeetCode] 010. Regular Expression Matching (Hard) (C++/Java/Python)
索引:[LeetCode]
Leetcode题解
索引(C++/Java/Python/Sql)Github:https://github.com/illuz/leetcode010.Regular_Expression_Matching
hcbbt
·
2020-07-07 09:23
=====算法相关=====
+基础算法
+Leetcode
Leetcode
题解
LeetCode题解
--2. Add Two Numbers
链接LeetCode题目:https://leetcode.com/problems/add-two-numbers/GitHub代码:https://github.com/gatieme/LeetCode/tree/master/002-AddTwoNumbersCSDN题解:http://blog.csdn.net/gatieme/article/details/50809402描述Youar
JeanCheng
·
2020-07-07 08:21
┈┈【LeetCode
面试题】
Leetcode题解
——算法思想之动态规划
斐波那契数列1.爬楼梯2.强盗抢劫3.强盗在环形街区抢劫4.信件错排5.母牛生产矩阵路径1.矩阵的最小路径和2.矩阵的总路径数数组区间1.数组区间和2.数组中等差递增子区间的个数分割整数1.分割整数的最大乘积2.按平方数来分割整数3.分割整数构成字母字符串最长递增子序列1.最长递增子序列2.一组整数对能够构成的最长链3.最长摆动子序列最长公共子序列0-1背包1.划分数组为和相等的两部分2.改变一组
dieshi8689
·
2020-07-07 06:11
leetcode题解
:第25题Reverse Nodes in k-Group
题目ReverseNodesink-GroupGivenalinkedlist,reversethenodesofalinkedlistkatatimeandreturnitsmodifiedlist.kisapositiveintegerandislessthanorequaltothelengthofthelinkedlist.Ifthenumberofnodesisnotamultipleo
chenf99
·
2020-07-07 05:11
算法
LeetCode题解
系列--309. Best Time to Buy and Sell Stock with Cooldown
描述Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteasmanytransactionsasyoulike(ie,buyoneandselloneshareofthestockmultipletimes)
bowen_wu_
·
2020-07-07 04:18
C++
leetcode
LeetCode题解
系列--123. Best Time to Buy and Sell Stock III
描述Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteatmosttwotransactions.Note:Youmaynotengageinmultipletransactionsatthesametim
bowen_wu_
·
2020-07-07 04:18
C++
leetcode
LeetCode题解
系列--763. Partition Labels
描述AstringSoflowercaselettersisgiven.Wewanttopartitionthisstringintoasmanypartsaspossiblesothateachletterappearsinatmostonepart,andreturnalistofintegersrepresentingthesizeoftheseparts.Example1:Input:S=
bowen_wu_
·
2020-07-07 04:46
C++
leetcode
LeetCode题解
系列--188. Best Time to Buy and Sell Stock IV
描述Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteatmostktransactions.Note:Youmaynotengageinmultipletransactionsatthesametime(
bowen_wu_
·
2020-07-07 04:46
C++
leetcode
LeetCode题解
系列--122. Best Time to Buy and Sell Stock II
描述Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteasmanytransactionsasyoulike(ie,buyoneandselloneshareofthestockmultipletimes)
bowen_wu_
·
2020-07-07 04:15
C++
leetcode
LeetCode题解
系列--718. Maximum Length of Repeated Subarray
描述GiventwointegerarraysAandB,returnthemaximumlengthofansubarraythatappearsinbotharrays.Example1:Input:A:[1,2,3,2,1]B:[3,2,1,4,7]Output:3Explanation:Therepeatedsubarraywithmaximumlengthis[3,2,1].Note:1
bowen_wu_
·
2020-07-07 04:15
C++
leetcode
LeetCode题解
系列--685. Redundant Connection II
描述Inthisproblem,arootedtreeisadirectedgraphsuchthat,thereisexactlyonenode(theroot)forwhichallothernodesaredescendantsofthisnode,pluseverynodehasexactlyoneparent,exceptfortherootnodewhichhasnoparents.T
bowen_wu_
·
2020-07-07 04:14
C++
leetcode
LeetCode题解
(Golang实现)--Longest Substring Without Repeating Characters
题目Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Examples:Given"abcabcbb",theansweris"abc",whichthelengthis3.Given"bbbbb",theansweris"b",withthelengthof1.Given"pwwkew",thean
EvansJang
·
2020-07-07 02:10
Go语言
LeetCode
LeetCode题解
-25-Reverse Nodes in k-Group
原题简介该题共有2种解法,一种迭代,一种递归。迭代法解题思路每一次取K个节点作为子链表,将其反转,然后将反转后的子链表添加到新的链表中。图解代码publicclassSolution25{publicListNodereverseKGroup(ListNodehead,intk){if(head==null||head.next==null||k0){//reversecurrentk-group
WangT443
·
2020-07-07 01:43
LeetCode
Leetcode题解
:4. Longest Substring Without Repeating Characters
Leetcode题解
:4.LongestSubstringWithoutRepeatingCharacters难度:Medium题目Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Examples
Littlecuter
·
2020-07-06 22:33
Leetcode~
leetcode题解
-25. Reverse Nodes in k-Group
题意:把原始链表k个k个的反转,如果最后剩余的不到k个结点,那么保持不变。例子:给定链表:1->2->3->4->5如果k=2,返回链表:2->1->4->3->5如果k=3,返回链表:3->2->1->4->5分析:前两天十大上有师兄分享17年算法岗面经时提到了本题,因此在做本题的时候也格外认真。晚上洗澡的时候理了一下思路,然后手写代码bug-free,还是很开心的。题目本身是几道题的综合,因此
北邮张博
·
2020-07-06 22:33
Leetcode题解
leetcode题解
-23. Merge k Sorted Lists
题意:合并k个有序的链表,分析描述算法的复杂度。分析:这道题目在分布式系统中非常常见,来自不同client的sortedlist要在centralserver上面merge起来。解法就是有点类似于归并排序的思路,就是分治法,不了解归并排序的朋友,请参见归并排序-维基百科,是一个比较经典的O(nlogn)的排序算法,还是比较重要的。思路是先分成两个子任务,然后递归求子任务,最后回溯回来。这个题目也是
北邮张博
·
2020-07-06 22:33
Leetcode题解
leetcode题解
-44. Wildcard Matching
分析:这道题和
leetcode题解
-10.RegularExpressionMatching相似,不同的是*可以匹配一串序列。
北邮张博
·
2020-07-06 22:33
Leetcode题解
Leetcode题解
-6.regular-expression-matching
[TOC]题目背景https://leetcode-cn.com/problems/longest-palindromic-substring/给你一个字符串s和一个字符规律p,请你来实现一个支持'.'和'*'的正则表达式匹配。'.'匹配任意单个字符'*'匹配零个或多个前面的那一个元素所谓匹配,是要涵盖整个字符串s的,而不是部分字符串。说明:s可能为空,且只包含从a-z的小写字母。p可能为空,且只
A94583879
·
2020-07-06 20:43
Leetcode题解
- 3. Longest Substring Without Repeating Characters
题目Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.给定一个字符串,找出其中最长的没有重复字符的子串。Examples:Given"abcabcbb",theansweris"abc",whichthelengthis3.Given"bbbbb",theansweris"b",withtheleng
xuelians
·
2020-07-06 20:02
LeetCode题解
——684. 冗余连接(并查集)
题目https://leetcode-cn.com/problems/redundant-connection/在本问题中,树指的是一个连通且无环的无向图。输入一个图,该图由一个有着N个节点(节点值不重复1,2,…,N)的树及一条附加的边构成。附加的边的两个顶点包含在1到N中间,这条附加的边不属于树中已存在的边。结果图是一个以边组成的二维数组。每一个边的元素是一对[u,v],满足u
从程序猿到程序员
·
2020-07-06 18:24
LeetCode
LeetCode题解
-3-Longest Substring Without Repeating Characters
解题思路首先要读懂题目,它要求的是找到最长的子串,并且子串中没有出现重复的字符。我的想法,是用一个map存储每个字符最后出现的位置,还要有个变量start,它用来记录上一次出现重复的位置,如果当前字符上一次出现的位置比start小,那么说明中间出现了重复,不能当成有效的子串。记得就是在扫描结束后,再判断一下最后一段子串。给个图简单说明一下。参考源码publicclassSolution{publi
小毛1983
·
2020-07-06 17:44
LeetCode
LeetCode题解
-10-Regular Expression Matching
解题思路思路是动态规划。假设s是待匹配字符串,p是表达式。定义数组matchs,其中matchs[i,j]表示s[0,i)和p[0,j)是否匹配,那么结果就是求matchs[s长度加1,p长度加1]。对于matchs[i,j]分以下情况:*i=0,j=0,空的肯定能匹配*i=0,j!=0,那么在j>1的情况下且p[j-1]是星号的时候,match[0,j]=match[0,j-2],相当于是.*结
小毛1983
·
2020-07-06 17:13
LeetCode
leetcode题解
-3. Longest Substring Without Repeating Characters
题目:Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Examples:Given“abcabcbb”,theansweris“abc”,whichthelengthis3.Given“bbbbb”,theansweris“b”,withthelengthof1.Given“pwwkew”,thea
liuchongee
·
2020-07-06 17:21
leetcode刷题
Leetcode题解
-3. Longest Substring Without Repeating Characters
3.LongestSubstringWithoutRepeatingCharactersGivenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Examples:Given"abcabcbb",theansweris"abc",whichthelengthis3.Given"bbbbb",theanswer
hzw2945
·
2020-07-06 16:49
Leetcode
Leetcode题解
-25. Reverse Nodes in k-Group
Leetcode题解
-25.ReverseNodesink-GroupGivenalinkedlist,reversethenodesofalinkedlistkatatimeandreturnitsmodifiedlist.kisapositiveintegerandislessthanorequaltothelengthofthelinkedlist.Ifthenumberofnodesisn
hzw2945
·
2020-07-06 16:49
Leetcode
Leetcode题解
-5. Longest Palindromic Substring
5.LongestPalindromicSubstringGivenastrings,findthelongestpalindromicsubstringins.Youmayassumethatthemaximumlengthofsis1000.Example:Input:"babad"Output:"bab"Note:"aba"isalsoavalidanswer.Example:Input:"
hzw2945
·
2020-07-06 16:49
Leetcode
《LeetBook》
leetcode题解
(10): Regular Expression Matching——DP解决正则匹配
我现在在做一个叫《leetbook》的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看书的地址:https://hk029.gitbooks.io/leetbook/010.RegularExpressionMatching问题Implementregularexpressionmatchingwithsupportfor‘.’and‘*
Vosky
·
2020-07-06 16:32
《LeetCode》解题笔记
Leetcode题解
——数据结构之树
递归1.树的高度2.平衡树3.两节点的最长路径4.翻转树5.归并两棵树6.判断路径和是否等于一个数7.统计路径和等于一个数的路径数量8.子树9.树的对称10.最小路径11.统计左叶子节点的和12.相同节点值的最大路径长度13.间隔遍历14.找出二叉树中第二小的节点层次遍历1.一棵树每层节点的平均数2.得到左下角的节点前中后序遍历1.非递归实现二叉树的前序遍历2.非递归实现二叉树的后序遍历3.非递归
dieshi8689
·
2020-07-06 16:25
LeetCode题解
系列--5. Longest Palindromic Substring
描述Givenastrings,findthelongestpalindromicsubstringins.Youmayassumethatthemaximumlengthofsis1000.Example:Input:“babad”Output:“bab”Note:“aba”isalsoavalidanswer.Example:Input:“cbbd”Output:“bb”难度:medium这道
bowen_wu_
·
2020-07-06 16:22
leetcode
leetcode
leetcode题解
第23题 Merge k Sorted Lists(合并K个排序链表)
题目大意如下:给定k个有序链表,请将这k个列表合并成一个有序链表,然后返回这个有序列表的头结点。在python中,链表被这样实现:#Definitionforsingly-linkedlist.classListNode:def__init__(self,x):self.val=xself.next=None样例输入:[1->4->5,1->3->4,2->6]样例输出:1->1->2->3->4
笔墨留年
·
2020-07-06 15:08
leetcode题解
【
LeetCode题解
---003】Longest Substring Without Repeating Characters
题目Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Example1:Input:"abcabcbb"Output:3Explanation:Theansweris"abc",withthelengthof3.Example2:Input:"bbbbb"Output:1Explanation:The
程序猿杂货铺
·
2020-07-06 15:52
LeetCode
【
LeetCode题解
-005】longest Palindrome Substring
题目Givenastrings,findthelongestpalindromicsubstringins.Youmayassumethatthemaximumlengthofsis1000.Example1:Input:"babad"Output:"bab"Note:"aba"isalsoavalidanswer.Example2:Input:"cbbd"Output:"bb"原题地址:http
程序猿杂货铺
·
2020-07-06 15:52
LeetCode
上一页
12
13
14
15
16
17
18
19
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他