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
lintCode
LintCode
之53 翻转字符串
题目来源:翻转字符串题目描述:给定一个字符串,逐个翻转字符串中的每个单词。样例:Java代码:publicclassSolution{/***@params:Astring*@return:Astring*/publicStringreverseWords(Strings){//writeyourcodeif(s.length()==0)return"";String[]res=s.split("
Guoshi_Wan
·
2018-02-26 23:12
LintCode刷题
[
LintCode
] Top k Largest Numbers II
ProblemImplementadatastructure,providetwointerfaces:add(number).Addanewnumberinthedatastructure.topk().Returnthetopklargestnumbersinthisdatastructure.kisgivenwhenwecreatethedatastructure.Examples=newS
linspiration
·
2018-02-26 00:00
堆排序
heap
java
[
LintCode
] Kth Prime Number
ProblemGiventheprimenumbern,outputthenumberofprimenumbersNoticen<=100000Theprimenumberisdefinedasanaturalnumbergreaterthan1,andtherearenootherfactorsexcept1andititself.ExampleGivenn=3,return2.explanat
linspiration
·
2018-02-26 00:00
leetcode
LintCode
mathematics
java
日常练习:
lintcode
:50. 数组剔除元素后的乘积
题目:给定一个整数数组A。定义B[i]=A[0]*…*A[i-1]*A[i+1]*…*A[n-1],计算B的时候请不要使用除法。样例:给出A=[1,2,3],返回B为[6,3,2]题…不难,就循环相乘,之后加到另一个数组里面就行上代码:classSolution:"""@param:nums:GivenanintegersarrayA@return:AlonglongarrayBandB[i]=A
Cold__Winter
·
2018-02-25 22:17
lintcode
算法相关问题以及对应解
LintCode
上的算法相关的问题,以及相对应的解,所有答案用Java实现斐波那契数列查找斐波纳契数列中第N个数的和。所谓的斐波纳契数列是指:前2个数是0和1。
GGGHub
·
2018-02-24 17:58
算法
[LeetCode][
LintCode
] Add Two Numbers
Youaregiventwonon-emptylinkedlistsrepresentingtwonon-negativeintegers.Thedigitsarestoredinreverseorderandeachoftheirnodescontainasingledigit.Addthetwonumbersandreturnitasalinkedlist.Youmayassumethetwo
codingEskimo
·
2018-02-21 12:00
[LeetCode][
LintCode
] Two Sum
思路:这道题因为只有一对,所以可以用hashmap,需要注意的是,数字可能有重复,eg.[1,2,2,3,4]target=4.所以最好的办法就是把剩下的放进去。这样如果有重复,没关系,把现在的index和已经放进去的index返回即可。classSolution{publicint[]twoSum(int[]nums,inttarget){int[]rst=newint[2];if(nums==
codingEskimo
·
2018-02-21 11:00
LintCode
165. Merge Two Sorted Lists
题目思路水题代码"""DefinitionofListNodeclassListNode(object):def__init__(self,val,next=None):self.val=valself.next=next"""classSolution:"""@param:l1:ListNodel1istheheadofthelinkedlist@param:l2:ListNodel2isthe
sparksnail
·
2018-02-19 01:15
OJ-LintCode
算法-链表
[
LintCode
] Swap Bits
Writeaprogramtoswapoddandevenbitsinanintegerwithasfewinstructionsaspossible(e.g.,bit0andbit1areswapped,bit2andbit3areswapped,andsoon).Example5=(101)2=>(1010)2=10思路:这道题需要知道的技巧是哪个数是evennumbermask,哪个是odd
codingEskimo
·
2018-02-14 11:00
Lintcode
365 Count 1 in Binary solution 题解
【题目链接】www.
lintcode
.com/en/problem/count-1-in-binary/【题目解析】最容易想到的方法是对数字依次右移,判断每一位是否为1,时间复杂度为o(n),n为数字有效位数
小姜同学
·
2018-02-10 00:00
LintCode
Lintcode
363 Trapping Rain Water solution 题解
【题目链接】www.
lintcode
.com/en/p
小姜同学
·
2018-02-09 00:00
LintCode
lintcode
-第k大的数
题目:在数组中找到第k大的元素样例:给出数组 [9,3,2,4,8],第三大的元素是 4给出数组 [1,2,3,4,5],第一大的元素是 5,第二大的元素是 4,第三大的元素是 3,以此类推/*** findKthMaxnumber*/publicstaticintkthLargestElement(intk,int[]nums){ if(null==nums||kk-1) //第k大
Ailubby
·
2018-02-08 15:39
排序
Lintcode
362 Sliding Window Maximum solution 题解
【题目描述】Givenanarrayofnintegerwithduplicatenumber,andamovingwindow(sizek),movethewindowateachiterationfromthestartofthearray,findthemaximumnumberinsidethewindowateachmoving.给出一个可能包含重复的整数数组,和一个大小为k的滑动窗口,
小姜同学
·
2018-02-08 00:00
LintCode
[
LintCode
] Missing String
ProblemGiventwostrings,youhavetofindthemissingstring.ExampleGivenastringstr1=ThisisanexampleGivenanotherstringstr2=isexampleReturn["This","an"]SolutionpublicclassSolution{/**@param:agivenstring*@param
linspiration
·
2018-02-08 00:00
hash
数组
string
java
LintCode
Lintcode
360 Sliding Window Median solution 题解
【题目描述】Givenanarrayofninteger,andamovingwindow(sizek),movethewindowateachiterationfromthestartofthearray,findthemedianoftheelementinsidethewindowateachmoving.(Ifthereareevennumbersinthearray,returntheN
小姜同学
·
2018-02-07 00:00
LintCode
Lintcode
247 Segment Tree Query II solution 题解
【题目描述】Foranarray,wecanbuildaSegmentTreeforit,eachnodestoresanextraattributecounttodenotethenumberofelementsinthethearraywhichvalueisbetweenintervalstartandend.(Thearraymaynotfullyfilledbyelements)Desi
小姜同学
·
2018-02-06 00:00
LintCode
lintcode
-两数之和-BST版本
题目:给一棵二叉搜索树以及一个整数 n,在树中找到和为 n 的两个数字样例:给一棵BST:4/\25/\13以及一个整数n= 3返回 [1,2] 或 [2,1]思路:遍历节点,在节点上判断另一个数是否存在代码:/** *DefinitionofTreeNode: *publicclassTreeNode{ * publicintval; * publicTreeNodeleft,right
Ailubby
·
2018-02-05 22:37
数据结构
[
LintCode
] String Homomorphism
ProblemGiventwostringssandt,determineiftheyareisomorphic.Twostringsareisomorphicifthecharactersinscanbereplacedtogett.Alloccurrencesofacharactermustbereplacedwithanothercharacterwhilepreservingtheorde
linspiration
·
2018-02-05 00:00
hashmap
string
leetcode
LintCode
java
[
LintCode
] Drop Eggs II
Thereisabuildingofnfloors.Ifaneggdropsfromthekthfloororabove,itwillbreak.Ifit'sdroppedfromanyfloorbelow,itwillnotbreak.You'regivenmeggs,Findkwhileminimizethenumberofdropsfortheworstcase.Returnthenumbe
codingEskimo
·
2018-02-02 12:00
[
LintCode
] Frog Jump
Afrogiscrossingariver.Theriverisdividedintoxunitsandateachunittheremayormaynotexistastone.Thefrogcanjumponastone,butitmustnotjumpintothewater.Givenalistofstones'positions(inunits)insortedascendingorde
codingEskimo
·
2018-02-02 12:00
LintCode
【简单】53. 翻转字符串 。代码及思路
题目要求:给定一个字符串,逐个翻转字符串中的每个单词。说明单词的构成:无空格字母构成一个单词输入字符串是否包括前导或者尾随空格?可以包括,但是反转后的字符不能包括如何处理两个单词间的多个空格?在反转字符串中间空格减少到只含一个思路:刚开始没搞明白,还以为是要把每一个单词内字母的前后顺序颠倒,原来是把单词顺序颠倒啊……第一步,如果是空则返回空。剩下的写了注释。代码:classSolution{pub
LimonSea
·
2018-02-02 00:44
LintCode
[
LintCode
] Jump Game
Givenanarrayofnon-negativeintegers,youareinitiallypositionedatthefirstindexofthearray.Eachelementinthearrayrepresentsyourmaximumjumplengthatthatposition.Determineifyouareabletoreachthelastindex.Notice
codingEskimo
·
2018-02-01 12:00
[
LintCode
] Knight Shortest Path II
Givenaknightinachessboardn*m(abinarymatrixwith0asemptyand1asbarrier).theknightinitialzepositionis(0,0)andhewantstoreachposition(n-1,m-1),Knightcanonlybefromlefttoright.Findtheshortestpathtothedestinat
codingEskimo
·
2018-02-01 11:00
日常练习:
lintcode
46. 主元素
题目:给定一个整型数组,找出主元素,它在数组中的出现次数严格大于数组元素个数的二分之一。样例:给出数组[1,1,1,1,2,2,2],返回1讲真哈,还是个水题,唉。也不知道明天的测验能咋样。上代码吧:classSolution:"""@param:nums:alistofintegers@return:findamajoritynumber"""defmajorityNumber(self,num
Cold__Winter
·
2018-01-26 21:24
python
lintcode
日常练习:
lintcode
64. 合并排序数组
题目:合并两个排序的整数数组A和B变成一个新的数组。样例:给出A=[1,2,3,empty,empty],B=[4,5]合并之后A将变成[1,2,3,4,5]那啥,讲真哈,这题不难,就直接上代码了:classSolution:"""@param:A:sortedintegerarrayAwhichhasmelements,butsizeofAism+n@param:m:Aninteger@para
Cold__Winter
·
2018-01-26 21:21
lintcode
日常练习:
lintcode
64. 合并排序数组
题目:合并两个排序的整数数组A和B变成一个新的数组。样例:给出A=[1,2,3,empty,empty],B=[4,5]合并之后A将变成[1,2,3,4,5]那啥,讲真哈,这题不难,就直接上代码了:classSolution:"""@param:A:sortedintegerarrayAwhichhasmelements,butsizeofAism+n@param:m:Aninteger@para
Cold__Winter
·
2018-01-26 21:21
lintcode
日常练习:
lintcode
56. 两数之和
题目:给一个整数数组,找到两个数使得他们的和等于一个给定的数target。你需要实现的函数twoSum需要返回这两个数的下标,并且第一个下标小于第二个下标。注意这里下标的范围是0到n-1。注意事项你可以假设只有一组答案。样例:给出numbers=[2,7,11,15],target=9,返回[0,1].上代码:classSolution:"""@param:numbers:AnarrayofInt
Cold__Winter
·
2018-01-25 23:12
python
lintcode
日常练习:
lintcode
56. 两数之和
题目:给一个整数数组,找到两个数使得他们的和等于一个给定的数target。你需要实现的函数twoSum需要返回这两个数的下标,并且第一个下标小于第二个下标。注意这里下标的范围是0到n-1。注意事项你可以假设只有一组答案。样例:给出numbers=[2,7,11,15],target=9,返回[0,1].上代码:classSolution:"""@param:numbers:AnarrayofInt
Cold__Winter
·
2018-01-25 23:12
lintcode
日常练习:
lintcode
39. 恢复旋转排序数组
题目:给定一个旋转排序数组,在原地恢复其排序。*说明:什么是旋转数组?比如,原始数组为[1,2,3,4],则其旋转数组可以是[1,2,3,4],[2,3,4,1],[3,4,1,2],[4,1,2,3]样例:[4,5,1,2,3]->[1,2,3,4,5]这个题以前做过一样的,呃….之前做的是旋转,这个是恢复,排一下序就好了python一句话解决:classSolution:"""@param:n
Cold__Winter
·
2018-01-25 17:58
lintcode
日常练习:
lintcode
39. 恢复旋转排序数组
题目:给定一个旋转排序数组,在原地恢复其排序。*说明:什么是旋转数组?比如,原始数组为[1,2,3,4],则其旋转数组可以是[1,2,3,4],[2,3,4,1],[3,4,1,2],[4,1,2,3]样例:[4,5,1,2,3]->[1,2,3,4,5]这个题以前做过一样的,呃….之前做的是旋转,这个是恢复,排一下序就好了python一句话解决:classSolution:"""@param:n
Cold__Winter
·
2018-01-25 17:58
lintcode
日常练习:
lintcode
172. 删除元素
题目:给定一个数组和一个值,在原地删除与值相同的数字,返回新数组的长度。元素的顺序可以改变,并且对新的数组不会有影响。样例:给出一个数组[0,4,4,0,0,2,4,4],和值4返回4并且4个元素的新数组为[0,0,0,2]这个题…看上去确实不难上代码:classSolution:"""@param:A:Alistofintegers@param:elem:Aninteger@return:The
Cold__Winter
·
2018-01-24 22:48
lintcode
日常练习:
lintcode
35. 翻转链表
题目:翻转一个链表样例:给出一个链表1->2->3->null,这个翻转后的链表为3->2->1->null心累…这个题以前做过,但是那个时候给定链表了,这次就考虑的比较少。先上代码吧…/***DefinitionofListNode**classListNode{*public:*intval;*ListNode*next;**ListNode(intval){*this->val=val;*t
Cold__Winter
·
2018-01-24 22:03
lintcode
日常练习+讨论:
lintcode
9. Fizz Buzz 问题
今天…Cisse-away突然问我是否做了这道题,我还心想这么简单的题不应该有什么蹊跷啊,但是他想问的题怎么可能简单呢,果然,他是看了
lintcode
网站上的挑战,只用一个if来完成这个题,还说用python
Cold__Winter
·
2018-01-23 19:35
lintcode
日常练习:
lintcode
53. 翻转字符串
题目:给定一个字符串,逐个翻转字符串中的每个单词。说明:单词的构成:无空格字母构成一个单词输入字符串是否包括前导或者尾随空格?可以包括,但是反转后的字符不能包括如何处理两个单词间的多个空格?在反转字符串中间空格减少到只含一个思路:这个我想到的是…先分割,再反转,刚开始想复杂了,以为单词里面的字母也要反转,后来发现是把分开的各个部分看成单独的元素,把整个分割开的字符串当成一个数组反转,用python
Cold__Winter
·
2018-01-23 13:03
lintcode
日常练习:
lintcode
53. 翻转字符串
题目:给定一个字符串,逐个翻转字符串中的每个单词。说明:单词的构成:无空格字母构成一个单词输入字符串是否包括前导或者尾随空格?可以包括,但是反转后的字符不能包括如何处理两个单词间的多个空格?在反转字符串中间空格减少到只含一个思路:这个我想到的是…先分割,再反转,刚开始想复杂了,以为单词里面的字母也要反转,后来发现是把分开的各个部分看成单独的元素,把整个分割开的字符串当成一个数组反转,用python
Cold__Winter
·
2018-01-23 13:03
lintcode
日常练习:
lintcode
157. 判断字符串是否没有重复字符
题目:实现一个算法确定字符串中的字符是否均唯一出现样例:给出”abc”,返回true给出”aab”,返回false这个题…我用的还是python,一句话解决直接把字符串转换成set,之后判断一下与原长度是否相等即可,简单方便。上代码:classSolution:"""@param:str:Astring@return:aboolean"""defisUnique(self,str):#writey
Cold__Winter
·
2018-01-23 13:23
lintcode
日常练习:
lintcode
157. 判断字符串是否没有重复字符
题目:实现一个算法确定字符串中的字符是否均唯一出现样例:给出”abc”,返回true给出”aab”,返回false这个题…我用的还是python,一句话解决直接把字符串转换成set,之后判断一下与原长度是否相等即可,简单方便。上代码:classSolution:"""@param:str:Astring@return:aboolean"""defisUnique(self,str):#writey
Cold__Winter
·
2018-01-23 13:23
lintcode
日常练习:
lintcode
6.合并排序数组 II
之前的这个版本不好看,用markdown重新写一遍。题目:合并两个排序的整数数组A和B变成一个新的数组。样例:给出A=[1,2,3,4],B=[2,4,5,6],返回[1,2,2,3,4,4,5,6]这个题….由于我用的是python,所以就比较简单,直接返回两个list合并完的排序版本就可以了。代码块classSolution:"""@param:A:sortedintegerarrayA@pa
Cold__Winter
·
2018-01-23 13:04
lintcode
日常练习:
lintcode
6.合并排序数组 II
之前的这个版本不好看,用markdown重新写一遍。题目:合并两个排序的整数数组A和B变成一个新的数组。样例:给出A=[1,2,3,4],B=[2,4,5,6],返回[1,2,2,3,4,4,5,6]这个题….由于我用的是python,所以就比较简单,直接返回两个list合并完的排序版本就可以了。代码块classSolution:"""@param:A:sortedintegerarrayA@pa
Cold__Winter
·
2018-01-23 13:04
lintcode
日常练习:
lintcode
3. 统计数字
这个是中等题目..我感觉我比上一个那个简单题目要简单一点…题目:计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例:例如n=12,k=1,在[0,1,2,3,4,5,6,7,8,9,10,11,12],我们发现1出现了5次(1,10,11,12)这里要注意的一点是,11这个数组算1出现了两次,这也是导致我出现了一次错误的点。因为是整数所以不方便直接判断互相直接是否包含,于是直接把整数转化
Cold__Winter
·
2018-01-22 23:10
lintcode
日常练习:
lintcode
3. 统计数字
这个是中等题目..我感觉我比上一个那个简单题目要简单一点…题目:计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例:例如n=12,k=1,在[0,1,2,3,4,5,6,7,8,9,10,11,12],我们发现1出现了5次(1,10,11,12)这里要注意的一点是,11这个数组算1出现了两次,这也是导致我出现了一次错误的点。因为是整数所以不方便直接判断互相直接是否包含,于是直接把整数转化
Cold__Winter
·
2018-01-22 23:10
lintcode
日常练习:
lintcode
8:旋转字符串
第二篇博客用markdown写,有点懵…不会用哇题目:给定一个字符串和一个偏移量,根据偏移量旋转字符串(从左向右旋转)样例:对于字符串“abcdefg”.offset=0=>“abcdefg”offset=1=>“gabcdef”offset=2=>“fgabcde”offset=3=>“efgabcd”个人看到的第一反应还是用python,查到了list的insert()函数,代码如下:defr
Cold__Winter
·
2018-01-22 22:30
lintcode
日常练习:
lintcode
8:旋转字符串
第二篇博客用markdown写,有点懵…不会用哇题目:给定一个字符串和一个偏移量,根据偏移量旋转字符串(从左向右旋转)样例:对于字符串“abcdefg”.offset=0=>“abcdefg”offset=1=>“gabcdef”offset=2=>“fgabcde”offset=3=>“efgabcd”个人看到的第一反应还是用python,查到了list的insert()函数,代码如下:defr
Cold__Winter
·
2018-01-22 22:30
lintcode
LintCode
【简单】56.两数之和 。代码及思路
这是我第一次在
LintCode
上刷题……以前在学校有刷过一点数据结构平台上的题,后来自己找其他oj,也没找到一个好看一点的……这次加入了学校为比赛准备的寒假训练,才接触到了
LintCode
,界面啊做题感受啊简直太美好了
LimonSea
·
2018-01-22 16:54
LintCode
【
LintCode
简单】451. 两两交换链表中的节点
1.问题描述:给一个链表,两两交换其中的节点,然后返回交换后的链表。2.样例:给出1->2->3->4,你应该返回的链表是2->1->4->3。3.代码:"""Definitionforsingly-linkedlist.classListNode:def__init__(self,x):self.val=xself.next=None"""classSolution:"""@param:head
麦片加奶不加糖
·
2018-01-22 13:49
#
LintCode
LintCode
Python
链表
2018愿望清单
4、增强coding能力,刷
lintcode
和leetcode,有自
进击的MsCat
·
2018-01-20 15:52
A+B problem
leetcode开始收费了,开始转战
lintcode
。
IMISSHOT
·
2018-01-19 10:32
LeetCode
【
LintCode
简单】46. 主元素
1.问题描述:给定一个整型数组,找出主元素,它在数组中的出现次数严格大于数组元素个数的二分之一。2.样例:给出数组[1,1,1,1,2,2,2],返回1。3.代码:classSolution:"""@param:nums:alistofintegers@return:findamajoritynumber"""defmajorityNumber(self,nums):#writeyourcodeh
麦片加奶不加糖
·
2018-01-16 21:40
#
LintCode
LintCode
Python
数组
[
LintCode
] Add Digits
ProblemGivenanon-negativeintegernum,repeatedlyaddallitsdigitsuntiltheresulthasonlyonedigit.ExampleGivennum=38.Theprocessislike:3+8=11,1+1=2.Since2hasonlyonedigit,return2.ChallengeCouldyoudoitwithoutan
linspiration
·
2018-01-16 00:00
LintCode
java
[
LintCode
] Word Count (Map Reduce)
ProblemUsingmapreducetocountwordfrequency.https://hadoop.apache.org/doc...Examplechunk1:"GoogleByeGoodByeHadoopcode"chunk2:"
lintcode
codeBye"GetMapReduceresult
linspiration
·
2018-01-16 00:00
mapreduce
上一页
58
59
60
61
62
63
64
65
下一页
按字母分类:
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
其他