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笔记
LeetCode笔记
:392. Is Subsequence
问题:Givenastringsandastringt,checkifsissubsequenceoft.YoumayassumethatthereisonlylowercaseEnglishlettersinbothsandt.tispotentiallyaverylong(length~=500,000)string,andsisashortstring(=1B,andyouwanttoche
Cloudox_
·
2017-11-23 09:06
LeetCode笔记
:445. Add Two Numbers II
问题:Youaregiventwonon-emptylinkedlistsrepresentingtwonon-negativeintegers.Themostsignificantdigitcomesfirstandeachoftheirnodescontainasingledigit.Addthetwonumbersandreturnitasalinkedlist.Youmayassumeth
Cloudox_
·
2017-11-23 09:52
LeetCode笔记
:442. Find All Duplicates in an Array
问题:Givenanarrayofintegers,1≤a[i]≤n(n=sizeofarray),someelementsappeartwiceandothersappearonce.Findalltheelementsthatappeartwiceinthisarray.CouldyoudoitwithoutextraspaceandinO(n)runtime?Example:Input:[4
Cloudox_
·
2017-11-23 09:48
LeetCode笔记
:462. Minimum Moves to Equal Array Elements II
问题:Givenanon-emptyintegerarray,findtheminimumnumberofmovesrequiredtomakeallarrayelementsequal,whereamoveisincrementingaselectedelementby1ordecrementingaselectedelementby1.Youmayassumethearray'slengthi
Cloudox_
·
2017-11-23 09:05
LeetCode笔记
:165. Compare Version Numbers
问题:Comparetwoversionnumbersversion1andversion2.Ifversion1>version2return1,ifversion1version2就返回,如果version1b)return1;elseif(a
Cloudox_
·
2017-11-23 09:22
LeetCode笔记
:168. Excel Sheet Column Title
问题:Givenapositiveinteger,returnitscorrespondingcolumntitleasappearinanExcelsheet.Forexample:1->A2->B3->C...26->Z27->AA28->AB大意:给出一个正整数,返回它对应的Excel表格中的列标题。例子:1->A2->B3->C...26->Z27->AA28->AB思路:我们找一下规律,
Cloudox_
·
2017-11-23 09:08
LeetCode笔记
:125. Valid Palindrome
问题:Givenastring,determineifitisapalindrome,consideringonlyalphanumericcharactersandignoringcases.Forexample,"Aman,aplan,acanal:Panama"isapalindrome."raceacar"isnotapalindrome.Note:Haveyouconsiderthatt
Cloudox_
·
2017-11-23 09:35
LeetCode笔记
:204. Count Primes
问题:Countthenumberofprimenumberslessthananon-negativenumber,n.大意:计算小于非负数n的质数个数。思路:题目很简短,就是个找质数的问题。我们知道最简单的质数就是2,3,5。。。那怎么计算往后的质数呢?质数的定义是除了自己以外没有任何因子,也就是不被任何数整除,也就是说,不会被这个数前面的任何质数和非质数整除,其实非质数也可以被质数整除,比如
Cloudox_
·
2017-11-22 16:50
LeetCode笔记
:28. Implement strStr()
问题:ImplementstrStr().Returnstheindexofthefirstoccurrenceofneedleinhaystack,or-1ifneedleisnotpartofhaystack.大意:实现strStr()。返回haystack中第一次出现needle的位置,如果needle不是haystack的一部分则返回-1。思路:最简单的做法就是遍历haystack,发现和
Cloudox_
·
2017-11-22 16:04
LeetCode笔记
:14. Longest Common Prefix
问题Writeafunctiontofindthelongestcommonprefixstringamongstanarrayofstrings.大意:写一个函数来寻找一个数组的字符串中最长的相同前缀。思路:题目描述很简单只有一句话,导致我理解错了,以为是找到存在的任意两个字符串最长的相同前缀,还写了一份代码出来,自己测试的时候发现题目想要的结果不符合才发现,其实是找整个数组的字符串都有的相同的
Cloudox_
·
2017-11-22 16:10
LeetCode笔记
:58. Length of Last Word
问题:Givenastringsconsistsofupper/lower-casealphabetsandemptyspacecharacters'',returnthelengthoflastwordinthestring.Ifthelastworddoesnotexist,return0.Note:Awordisdefinedasacharactersequenceconsistsofnon
Cloudox_
·
2017-11-22 14:00
LeetCode笔记
:299. Bulls and Cows
问题:YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessm
Cloudox_
·
2017-11-22 11:48
LeetCode笔记
:172. Factorial Trailing Zeroes
问题:Givenanintegern,returnthenumberoftrailingzeroesinn!.Note:Yoursolutionshouldbeinlogarithmictimecomplexity.大意:给出一个整数n,返回n!后面0的个数。注意:你的算法时间复杂度要是logn以内。思路:这道题的要求是计算n的阶乘后面0的个数,而且要求算法时间复杂度为logn,那么就绝对不是要人
Cloudox_
·
2017-11-22 08:05
LeetCode笔记
:66. Plus One
问题:Givenanon-negativenumberrepresentedasanarrayofdigits,plusonetothenumber.Thedigitsarestoredsuchthatthemostsignificantdigitisattheheadofthelist.大意:给出一个非负数的代表数字的数组,给这个“数字”加一。这个数字的存储形式为最高位的数再数组的最前端。思路:
Cloudox_
·
2017-11-21 10:50
LeetCode笔记
:107. Binary Tree Level Order Traversal II
问题:Givenabinarytree,returnthebottom-uplevelordertraversalofitsnodes'values.(ie,fromlefttoright,levelbylevelfromleaftoroot).Forexample:Givenbinarytree[3,9,20,null,null,15,7],image.pngreturnitsbottom-up
Cloudox_
·
2017-11-21 10:49
LeetCode笔记
:342. Power of Four
问题:Givenaninteger(signed32bits),writeafunctiontocheckwhetheritisapowerof4.Example:Givennum=16,returntrue.Givennum=5,returnfalse.Followup:Couldyousolveitwithoutloops/recursion?大意:给出一个数字(有符号32位),写一个函数来检
Cloudox_
·
2017-11-21 10:32
LeetCode笔记
:70. Climbing Stairs
问题:Youareclimbingastaircase.Ittakesnstepstoreachtothetop.Eachtimeyoucaneitherclimb1or2steps.Inhowmanydistinctwayscanyouclimbtothetop?大意:你在爬一个楼梯。需要n节楼梯到达顶部。每次你可以爬一节或者两节楼梯。你总共有多少种爬到顶部的方法?思路:总觉得这个题目小时候做过
Cloudox_
·
2017-11-21 10:50
LeetCode笔记
:191. Number of 1 Bits
问题:Writeafunctionthattakesanunsignedintegerandreturnsthenumberof’1'bitsithas(alsoknownastheHammingweight).Forexample,the32-bitinteger’11'hasbinaryrepresentation00000000000000000000000000001011,sothefu
Cloudox_
·
2017-11-21 10:51
LeetCode笔记
:231. Power of Two
问题:Givenaninteger,writeafunctiontodetermineifitisapoweroftwo.大意:给出一个整数,写一个函数判断它是否是2的次方数。思路:这道题和另一道判断是否是3的次方数的题目很像,但是这个更简单,因为有一个二进制的东西存在,我们要判断一个数是不是2的次方数,不用去一次次除以2,也不用用log去算,直接转换成二进制,如果是2的次方数,那一定是最高位为1
Cloudox_
·
2017-11-21 09:16
LeetCode笔记
:387. First Unique Character in a String
问题:Givenastring,findthefirstnon-repeatingcharacterinitandreturnit'sindex.Ifitdoesn'texist,return-1.Examples:s="leetcode"return0.s="loveleetcode",return2.Note:Youmayassumethestringcontainonlylowercasel
Cloudox_
·
2017-11-21 09:50
LeetCode笔记
:389. Find the Difference
问题:Giventwostringssandtwhichconsistofonlylowercaseletters.Stringtisgeneratedbyrandomshufflingstringsandthenaddonemoreletteratarandomposition.Findtheletterthatwasaddedint.大意:给出两个完全有小写字母组成的字符串s和t。字符串t是由
Cloudox_
·
2017-11-21 09:43
LeetCode笔记
:136. Single Number
问题:Givenanarrayofintegers,everyelementappearstwiceexceptforone.Findthatsingleone.Note:Youralgorithmshouldhavealinearruntimecomplexity.Couldyouimplementitwithoutusingextramemory?大意:给出一个整数数组,其中每个元素都出现了两
Cloudox_
·
2017-11-21 09:52
LeetCode笔记
:171. Excel Sheet Column Number
题目:RelatedtoquestionExcelSheetColumnTitleGivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.Forexample:A->1B->2C->3...Z->26AA->27AB->28大意:与题目ExcelSheetColumnTitle相关给一个像Excel中显示
Cloudox_
·
2017-11-19 10:09
LeetCode笔记
-- LongestSubStringLength
拖了1天,今天顶着疲惫写了这篇笔记.这是最终完成的代码(借鉴了一部分网上的讨论)。publicintlengthOfLongestSubstring(Strings){intmaxlength=0,length=s.length(),t_location=0;int[]location=newint[256];for(inti=0;i0?Math.max(t_location,location[s
Mr_Carter
·
2017-10-03 23:37
LeetCode笔记
:309. Best Time to Buy and Sell Stock with Cooldown
问题:Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteasmanytransactionsasyoulike(ie,buyoneandselloneshareofthestockmultipletimes
Cloudox_
·
2017-04-26 10:54
LeetCode
LeetCode笔记
LeetCode笔记
:89. Gray Code
问题:Thegraycodeisabinarynumeralsystemwheretwosuccessivevaluesdifferinonlyonebit.Givenanon-negativeintegernrepresentingthetotalnumberofbitsinthecode,printthesequenceofgraycode.Agraycodesequencemustbegin
Cloudox_
·
2017-04-25 09:45
LeetCode
LeetCode笔记
LeetCode笔记
:96. Unique Binary Search Trees
问题:Givenn,howmanystructurallyuniqueBST’s(binarysearchtrees)thatstorevalues1…n?Forexample,Givenn=3,thereareatotalof5uniqueBST’s.大意:给出n,包含1~n这些节点可以形成多少个不同的BST(二叉查找树)?比如,给出n=3,有5个不同的BST:思路:二叉查找树的性质是左子节点一
Cloudox_
·
2017-04-19 09:40
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:386. Lexicographical Numbers
问题:Givenanintegern,return1-ninlexicographicalorder.Forexample,given13,return:[1,10,11,12,13,2,3,4,5,6,7,8,9].Pleaseoptimizeyouralgorithmtouselesstimeandspace.Theinputsizemaybeaslargeas5,000,000.思路:给出一
Cloudox_
·
2017-04-18 09:04
LeetCode
LeetCode笔记
LeetCode笔记
:424. Longest Repeating Character Replacement
问题:GivenastringthatconsistsofonlyuppercaseEnglishletters,youcanreplaceanyletterinthestringwithanotherletteratmostktimes.Findthelengthofalongestsubstringcontainingallrepeatinglettersyoucangetafterperfo
Cloudox_
·
2017-04-08 20:13
LeetCode
LeetCode笔记
LeetCode笔记
:424. Longest Repeating Character Replacement
问题:GivenastringthatconsistsofonlyuppercaseEnglishletters,youcanreplaceanyletterinthestringwithanotherletteratmostktimes.Findthelengthofalongestsubstringcontainingallrepeatinglettersyoucangetafterperfo
Cloudox_
·
2017-04-08 20:13
LeetCode
LeetCode笔记
leetcode
LeetCode笔记
:46. Permutations
问题:Givenacollectionofdistinctnumbers,returnallpossiblepermutations.Forexample,[1,2,3]havethefollowingpermutations:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]大意:给出一个不同数字的集合,返回所有可能的排列。比如:[1,2,3]有下
Cloudox_
·
2017-04-06 09:07
LeetCode
LeetCode笔记
LeetCode笔记
:328. Odd Even Linked List
问题Givenasinglylinkedlist,groupalloddnodestogetherfollowedbytheevennodes.Pleasenoteherewearetalkingaboutthenodenumberandnotthevalueinthenodes.Youshouldtrytodoitinplace.TheprogramshouldruninO(1)spacecom
Cloudox_
·
2017-03-30 10:04
LeetCode
LeetCode笔记
LeetCode笔记
:423. Reconstruct Original Digits from English
问题:Givenanon-emptystringcontaininganout-of-orderEnglishrepresentationofdigits0-9,outputthedigitsinascendingorder.Note:1、InputcontainsonlylowercaseEnglishletters.2、Inputisguaranteedtobevalidandcanbetra
Cloudox_
·
2017-03-29 10:32
LeetCode
LeetCode笔记
LeetCode笔记
:423. Reconstruct Original Digits from English
问题:Givenanon-emptystringcontaininganout-of-orderEnglishrepresentationofdigits0-9,outputthedigitsinascendingorder.Note:1、InputcontainsonlylowercaseEnglishletters.2、Inputisguaranteedtobevalidandcanbetra
Cloudox_
·
2017-03-29 10:32
LeetCode
LeetCode笔记
LeetCode笔记
:318. Maximum Product of Word Lengths
问题:Givenastringarraywords,findthemaximumvalueoflength(word[i])*length(word[j])wherethetwowordsdonotsharecommonletters.Youmayassumethateachwordwillcontainonlylowercaseletters.Ifnosuchtwowordsexist,retu
Cloudox_
·
2017-03-28 09:41
LeetCode
LeetCode笔记
LeetCode笔记
:503. Next Greater Element II
问题:Givenacirculararray(thenextelementofthelastelementisthefirstelementofthearray),printtheNextGreaterNumberforeveryelement.TheNextGreaterNumberofanumberxisthefirstgreaternumbertoitstraversing-ordernex
Cloudox_
·
2017-03-17 09:18
LeetCode
LeetCode笔记
LeetCode笔记
:503. Next Greater Element II
问题:Givenacirculararray(thenextelementofthelastelementisthefirstelementofthearray),printtheNextGreaterNumberforeveryelement.TheNextGreaterNumberofanumberxisthefirstgreaternumbertoitstraversing-ordernex
Cloudox_
·
2017-03-17 09:18
LeetCode
LeetCode笔记
LeetCode笔记
:508. Most Frequent Subtree Sum
问题:Giventherootofatree,youareaskedtofindthemostfrequentsubtreesum.Thesubtreesumofanodeisdefinedasthesumofallthenodevaluesformedbythesubtreerootedatthatnode(includingthenodeitself).Sowhatisthemostfrequ
Cloudox_
·
2017-03-15 10:31
LeetCode
LeetCode笔记
LeetCode笔记
:508. Most Frequent Subtree Sum
问题:Giventherootofatree,youareaskedtofindthemostfrequentsubtreesum.Thesubtreesumofanodeisdefinedasthesumofallthenodevaluesformedbythesubtreerootedatthatnode(includingthenodeitself).Sowhatisthemostfrequ
Cloudox_
·
2017-03-15 10:31
LeetCode
LeetCode笔记
LeetCode笔记
:526. Beautiful Arrangement
问题:SupposeyouhaveNintegersfrom1toN.WedefineabeautifularrangementasanarraythatisconstructedbytheseNnumberssuccessfullyifoneofthefollowingistruefortheithposition(1≤i≤N)inthisarray:Thenumberattheithposit
Cloudox_
·
2017-03-14 09:27
LeetCode
LeetCode笔记
LeetCode笔记
:515. Find Largest Value in Each Tree Row
问题:Youneedtofindthelargestvalueineachrowofabinarytree.Example:Input:Output:[1,3,9]大意:你需要找到二叉树中每一行最大的值。例子:输入:输出:[1,3,9]思路:要找每一行最大的数,我们总归是要遍历二叉树的,遍历二叉树分为BFS和DFS,这里我们要找每行最大的数,那么我们就用BFS,一行行分析过去。还记得我们在传送门:
Cloudox_
·
2017-03-13 14:00
LeetCode
LeetCode笔记
LeetCode笔记
:513. Find Bottom Left Tree Value
问题:Givenabinarytree,findtheleftmostvalueinthelastrowofthetree.Example1:Input:Output:1Example2:Input:Output:7Note:Youmayassumethetree(i.e.,thegivenrootnode)isnotNULL.大意:给出一个二叉树,找到树最下一行的最左边的节点值。例1:输入:输出
Cloudox_
·
2017-03-08 09:38
LeetCode
LeetCode笔记
LeetCode笔记
:513. Find Bottom Left Tree Value
问题:Givenabinarytree,findtheleftmostvalueinthelastrowofthetree.Example1:Input:Output:1Example2:Input:Output:7Note:Youmayassumethetree(i.e.,thegivenrootnode)isnotNULL.大意:给出一个二叉树,找到树最下一行的最左边的节点值。例1:输入:输出
Cloudox_
·
2017-03-08 09:38
LeetCode
LeetCode笔记
LeetCode笔记
:454. 4Sum II
问题:GivenfourlistsA,B,C,Dofintegervalues,computehowmanytuples(i,j,k,l)therearesuchthatA[i]+B[j]+C[k]+D[l]iszero.Tomakeproblemabiteasier,allA,B,C,DhavesamelengthofNwhere0≤N≤500.Allintegersareintherangeo
Cloudox_
·
2017-01-20 09:54
LeetCode
LeetCode笔记
LeetCode笔记
:392. Is Subsequence
问题:Givenastringsandastringt,checkifsissubsequenceoft.YoumayassumethatthereisonlylowercaseEnglishlettersinbothsandt.tispotentiallyaverylong(length~=500,000)string,andsisashortstring(=1B,andyouwanttoche
Cloudox_
·
2017-01-17 14:25
LeetCode
LeetCode笔记
LeetCode笔记
:343. Integer Break
问题:Givenapositiveintegern,breakitintothesumofatleasttwopositiveintegersandmaximizetheproductofthoseintegers.Returnthemaximumproductyoucanget.Forexample,givenn=2,return1(2=1+1);givenn=10,return36(10=3+
Cloudox_
·
2017-01-16 15:09
LeetCode
LeetCode笔记
LeetCode笔记
:482. License Key Formatting
问题:NowyouaregivenastringS,whichrepresentsasoftwarelicensekeywhichwewouldliketoformat.ThestringSiscomposedofalphanumericalcharactersanddashes.Thedashessplitthealphanumericalcharacterswithinthestringint
Cloudox_
·
2017-01-13 09:01
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:481. Magical String
问题:AmagicalstringSconsistsofonly‘1’and‘2’andobeysthefollowingrules:ThestringSismagicalbecauseconcatenatingthenumberofcontiguousoccurrencesofcharacters‘1’and‘2’generatesthestringSitself.Thefirstfewelem
Cloudox_
·
2017-01-12 10:13
LeetCode
LeetCode笔记
LeetCode笔记
:238. Product of Array Except Self
问题:Givenanarrayofnintegerswheren>1,nums,returnanarrayoutputsuchthatoutput[i]isequaltotheproductofalltheelementsofnumsexceptnums[i].SolveitwithoutdivisionandinO(n).Forexample,given[1,2,3,4],return[24,1
Cloudox_
·
2017-01-06 09:13
LeetCode
LeetCode笔记
LeetCode笔记
:442. Find All Duplicates in an Array
问题:Givenanarrayofintegers,1≤a[i]≤n(n=sizeofarray),someelementsappeartwiceandothersappearonce.Findalltheelementsthatappeartwiceinthisarray.CouldyoudoitwithoutextraspaceandinO(n)runtime?Example:Input:[4
Cloudox_
·
2017-01-05 09:43
LeetCode
LeetCode笔记
上一页
7
8
9
10
11
12
13
14
下一页
按字母分类:
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
其他