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刷题记录
——第167题(两数之和二)
题目描述给定一个已按照升序排列的有序数组,找到两个数使得它们相加之和等于目标数。函数应该返回这两个下标值index1和index2,其中index1必须小于index2。说明:返回的下标值(index1和index2)不是从零开始的。你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。示例:输入:numbers=[2,7,11,15],target=9输出:[1,2]解释:2与7之
人工智障1025
·
2018-12-20 10:54
菜鸟的LeetCode刷题记录
LeetCode刷题记录
——第七十题(爬楼梯)
题目描述假设你正在爬楼梯。需要n阶你才能到达楼顶。每次你可以爬1或2个台阶。你有多少种不同的方法可以爬到楼顶呢?注意:给定n是一个正整数。示例1:输入:2输出:2解释:有两种方法可以爬到楼顶。1阶+1阶2阶示例2:输入:3输出:3解释:有三种方法可以爬到楼顶。1阶+1阶+1阶1阶+2阶2阶+1阶思路分析因为只可以爬一个或者两个台阶,相当于上第k个台阶时只可能是从第k-1和第k-2个台阶爬上来,所以
人工智障1025
·
2018-12-19 09:58
菜鸟的LeetCode刷题记录
LeetCode刷题记录
——第二十八题(实现strStr())
28.实现strStr()题目描述思路分析代码实现题目描述实现strStr()函数。给定一个haystack字符串和一个needle字符串,在haystack字符串中找出needle字符串出现的第一个位置(从0开始)。如果不存在,则返回-1。示例1:输入:haystack=“hello”,needle=“ll”输出:2示例2:示例2:输入:haystack=“aaaaa”,needle=“bba”
人工智障1025
·
2018-12-17 14:44
菜鸟的LeetCode刷题记录
LeetCode刷题记录
——第二十题(有效的括号)
20.有效的括号题目描述思路分析代码实现题目描述给定一个只包括‘(’,’)’,’{’,’}’,’[’,’]’的字符串,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。示例1:输入:“()”输出:true示例2:输入:“(]”输出:false思路分析确定括号是否匹配的方法:利用字典的key-value对,将前一项p
人工智障1025
·
2018-12-14 13:58
菜鸟的LeetCode刷题记录
LeetCode刷题记录
13——705. Design HashSet(easy)
LeetCode刷题记录
13——705.DesignHashSet(easy)目录
LeetCode刷题记录
13——705.DesignHashSet(easy)前言题目语言思路源码后记前言今天贼热题目今天的题目是关于哈希表的
LLyj_
·
2018-12-05 23:00
LeetCode
LeetCode刷题记录
11——290. Word Pattern(easy)
LeetCode刷题记录
11——290.WordPattern(easy)目录
LeetCode刷题记录
11——290.WordPattern(easy)题目语言思路源码后记题目本题输入是两个字符串,输出是
LLyj_
·
2018-12-01 09:26
LeetCode
LeetCode刷题记录
2——217. Contains Duplicate(easy)
LeetCode刷题记录
2——217.ContainsDuplicate(easy)目录
LeetCode刷题记录
2——217.ContainsDuplicate(easy)题目语言思路后记题目今天这题是与数组相关的
LLyj_
·
2018-11-25 19:37
LeetCode
【
LeetCode刷题记录
】【3】无重复字符的最长子串
想到的方法还是不错的,速度也不错。classSolution{public:intlengthOfLongestSubstring(strings){inti,j,k;intmax=0;intsleng=s.length();int*count=newint[sleng];count[sleng-1]=1;//最后一个子串必然为1长度for(i=0;i=0;k--){if(k+count[k]>i
Czusual
·
2018-08-17 17:10
学习日记
leetCode刷题记录
1.minimum-depth-of-binary-treeGivenabinarytree,finditsminimumdepth.Theminimumdepthisthenumberofnodesalongtheshortestpathfromtherootnodedowntothenearestleafnode.使用广度优先搜索,类似层次遍历我们把一层一层往下搜索,遇到第一个左右子树都为nu
_ostreamBaba
·
2018-08-11 18:59
牛客网
【
LeetCode刷题记录
】【2】两数相加
/***Definitionforsingly-linkedlist.*structListNode{*intval;*ListNode*next;*ListNode(intx):val(x),next(NULL){}*};*/classSolution{public:ListNode*addTwoNumbers(ListNode*l1,ListNode*l2){ListNode*res=newL
Czusual
·
2018-08-06 11:18
学习日记
大一的
LeetCode刷题记录
LeetCode刷题记录
CreatedAt2018-04-0518:51当前进度:24/5931.两数之和给定一个整数数列,找出其中和为特定值的那两个数。
N0tExpectErr0r
·
2018-04-06 16:15
算法
LeetCode刷题记录
(第十五天)
ReshapetheMatrix原题目:InMATLAB,thereisaveryusefulfunctioncalled'reshape',whichcanreshapeamatrixintoanewonewithdifferentsizebutkeepitsoriginaldata.You'regivenamatrixrepresentedbyatwo-dimensionalarray,and
旭小白灬
·
2018-04-04 23:33
算法
java
LeetCode刷题记录
(第六天)
SwapSalary这道题竟然是一个sql题,虽然经常写sql和看关于mysql的性能优化,但是我发现一个大问题,我都白学来。。。。题目:Givenatablesalary,suchastheonebelow,thathasm=maleandf=femalevalues.Swapallfandmvalues(i.e.,changeallfvaluestomandviceversa)withasin
旭小白灬
·
2018-03-25 22:54
算法
LeetCode刷题记录
(第五天)
TrappingRainWater原题目:Givennnon-negativeintegersrepresentinganelevationmapwherethewidthofeachbaris1,computehowmuchwateritisabletotrapafterraining.翻译后:给定n个非负整数来表示每个柱的宽度为1的高程图,计算下雨后它能够捕集多少水。解释:首先看到题后(翻译后
旭小白灬
·
2018-03-23 23:14
算法
LeetCode刷题记录
(python3)
由于之前对算法题接触不多,因此暂时只做easy和medium难度的题.看完了《算法(第四版)》后重新开始刷LeetCode了,这次决定按topic来刷题,有一个大致的方向.有些题不止包含在一个topic中,就以我自己做的先后顺序为准了.Array---11.ContainerWithMostWater给定许多条与y轴平行的直线,求其中两条直线与x轴围成的容器的最大容量.这道题用到了双指针的思想.我
Limitlessun
·
2018-03-08 18:00
LeetCode刷题记录
1-两数之和
题目定给一个整数数组nums状语从句:一个目标值target,请在你该数组中找出状语从句:为目标值的那两个整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。示例:给定nums=[2,7,11,15],target=9因为nums[0]+nums[1]=2+7=9所以返回[0,1]普通解法时间O(n^2),空间O(1)这可能是大家最快能想到的方
allenxguo
·
2017-11-10 22:56
C++
Python
LeetCode刷题记录
(easy难度1-20题)
leetcode刷题记录
本文记录一下
leetcode刷题记录
,记录一下自己的解法和心得。
EarthChen
·
2017-08-15 17:20
【
LeetCode刷题记录
】9. Palindrome Number
Description:Determinewhetheranintegerisapalindrome.Dothiswithoutextraspace.这道题目实现并不难,但题目要求空间复杂度为O(1),有一定的技巧性。Solutions:Solution1:publicbooleanisPalindrome(intx){intpalindromeX=0;intinputX=x;while(x>0)
Mars_J
·
2017-04-26 22:47
LeetCode
【
LeetCode刷题记录
】7.Reverse Integer
Description:Reversedigitsofaninteger.Example1:x=123,return321Example2:x=-123,return-321Haveyouthoughtaboutthis?Herearesomegoodquestionstoaskbeforecoding.Bonuspointsforyouifyouhavealreadythoughtthrough
Mars_J
·
2017-04-25 20:02
LeetCode
【
LeetCode刷题记录
】1.Two Sum解法与Hashmap的应用
Description:Givenanarrayofintegers,returnindicesofthetwonumberssuchthattheyadduptoaspecifictarget.Youmayassumethateachinputwouldhaveexactlyonesolution,andyoumaynotusethesameelementtwice.Example:Givenn
Mars_J
·
2017-04-24 14:45
LeetCode
LeetCode 456. 132 Pattern——
LeetCode刷题记录
于是我要开始做俗之又俗的
leetCode刷题记录
了。一方面是贡献给大家题目的解,另一方面是督促自己刷题,希望每天都有至少一篇刷题的记录。
yt4766269
·
2016-12-07 00:05
Java
leetcode
leetCode刷题记录
(1)Linked List Cycle Total Accepted: 13297 Total Submissions: 38411 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra
·
2015-11-11 05:39
LeetCode
LeetCode刷题记录
1.TwoSum2.AddTwoNumbers 3.LongestSubstringWithoutRepeatingCharacters 4.MedianofTwoSortedArrays5.LongestPalindromicSubstring6.ZigZagConversion7.ReverseInteger8.StringtoInteger(atoi)9.PalindromeNumber10
YRB
·
2015-10-10 22:00
[
LeetCode刷题记录
]Number of Islands
Givena2dgridmapof '1's(land)and '0's(water),countthenumberofislands.Anislandissurroundedbywaterandisformedbyconnectingadjacentlandshorizontallyorvertically.Youmayassumeallfouredgesofthegridareallsurro
CiaoLiang
·
2015-04-09 14:00
[
LeetCode刷题记录
]Search in Rotated Sorted Array
Supposeasortedarrayisrotatedatsomepivotunknowntoyoubeforehand.(i.e., 0124567 mightbecome 4567012).Youaregivenatargetvaluetosearch.Iffoundinthearrayreturnitsindex,otherwisereturn-1.Youmayassumenoduplic
CiaoLiang
·
2015-04-08 13:00
[
LeetCode刷题记录
]Partition List
Givenalinkedlistandavalue x,partitionitsuchthatallnodeslessthan x comebeforenodesgreaterthanorequalto x.Youshouldpreservetheoriginalrelativeorderofthenodesineachofthetwopartitions.Forexample,Given 1->
CiaoLiang
·
2015-04-08 13:00
[
LeetCode刷题记录
]Length of Last Word
Givenastring s consistsofupper/lower-casealphabetsandemptyspacecharacters '',returnthelengthoflastwordinthestring.Ifthelastworddoesnotexist,return0.Note: Awordisdefinedasacharactersequenceconsistsofno
CiaoLiang
·
2015-04-08 13:00
[
LeetCode刷题记录
]Single Number II
Givenanarrayofintegers,everyelementappears three timesexceptforone.Findthatsingleone.Note:Youralgorithmshouldhavealinearruntimecomplexity.Couldyouimplementitwithoutusingextramemory?思路:实现一种操作,3个相同的数字操作
CiaoLiang
·
2015-04-08 13:00
[
LeetCode刷题记录
]Reverse Words in a String
Givenaninputstring,reversethestringwordbyword.Forexample,Givens="theskyisblue",return"blueisskythe".思路:每次遇到空格把每个单词反转,然后把整个字符串反转。边界条件注意:开始的多个空格跳过,结尾的多个空格删掉。单词中间间隔的多个空格变成一个。建议实现,就是把处理空格的字符串从字符串开始重写,然后反转
CiaoLiang
·
2015-04-08 12:00
[
LeetCode刷题记录
]190-191 Number of 1 Bits & Reverse Bits
Writeafunctionthattakesanunsignedintegerandreturnsthenumberof’1'bitsithas(alsoknownasthe Hammingweight).Forexample,the32-bitinteger’11'hasbinaryrepresentation 00000000000000000000000000001011,sothefun
CiaoLiang
·
2015-03-12 12:00
LeetCode
二进制
上一页
4
5
6
7
8
9
10
11
下一页
按字母分类:
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
其他