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
Wiggle Sort II
问题描述:Givenanunsortedarraynums,reorderitsuchthatnums[0]nums[2]=0;i--){nums[i]=nums[i/2];}for(i=0;i
ziyue225
·
2016-03-04 17:54
刷题心得
LintCode
直方图最大矩形覆盖
问题描述:给出的n个非负整数表示每个直方图的高度,每个直方图的宽均为1,在直方图中找到最大的矩形面积。以上直方图宽为1,高度为[2,1,5,6,2,3]。最大矩形面积如图阴影部分所示,含有10单位。分享本题的一种”暴力“解法。矩形的最大面积由宽度和该宽度范围内最低的高度决定。因此进行两次遍历,第一次遍历数组中的每一个元素;第二次以该元素为中心向左右两个方向遍历,当遍历到比该元素小的元素时,遍历停止
ziyue225
·
2016-03-04 17:36
刷题心得
LintCode
最大数
问题描述:给出一组非负整数,重新排列他们的顺序把他们组成一个最大的整数。给出[1,20,23,4,8],返回组合最大的整数应为8423201。显然这是一道排序的题目,易知应该把首位大的数字排在前,首位小的数字排在后。但当数据集为[2,20,21,24](一个例子)时,仅通过判断最高位不能完成排序,所以选用另一种方法。参考冒泡排序,两两比较并交换。比如1和20,1200){a=a/10;i1++;}
ziyue225
·
2016-03-04 09:48
刷题心得
lintcode
-easy-Product of Array Exclude Itself
GivenanintegersarrayA.DefineB[i]=A[0]*...*A[i-1]*A[i+1]*...*A[n-1],calculateB WITHOUT divideoperation.ForA= [1,2,3],return [6,3,2].publicclassSolution{ /** *@paramA:GivenanintegersarrayA *@return:A
哥布林工程师
·
2016-03-03 13:00
lintcode
-easy-Plus One
Givenanon-negativenumberrepresentedasanarrayofdigits,plusonetothenumber.Thedigitsarestoredsuchthatthemostsignificantdigitisattheheadofthelist.Given [1,2,3] whichrepresents123,return [1,2,4].Given [9,9
哥布林工程师
·
2016-03-03 13:00
lintcode
-easy-Partition List
Givenalinkedlistandavalue x,partitionitsuchthatallnodeslessthan x comebeforenodesgreaterthanorequalto x.Youshouldpreservetheoriginalrelativeorderofthenodesineachofthetwopartitions.Forexample,Given 1->
哥布林工程师
·
2016-03-03 09:00
lintcode
-easy-O(1) Check Power of 2
UsingO(1)timetocheckwhetheraninteger n isapowerof 2.For n=4,return true;For n=5,return false; 这道题就是看一下这个int二进制各位上总共是否只有一个1,如果只有一个1则是2的n次方。但是要注意特殊情况,如果这个数是Integer.MIN_VALUE,也只有一位是1,但是这个数是负数,所以不是2的n次方。c
哥布林工程师
·
2016-03-03 07:00
lintcode
-easy-Number of Islands
Givenaboolean2Dmatrix,findthenumberofislands. Givengraph:[ [1,1,0,0,0], [0,1,0,0,1], [0,0,0,1,1], [0,0,0,0,0], [0,0,0,0,1] ] return 3. publicclassSolution{ /** *@paramgridaboolean2Dmatrix *@
哥布林工程师
·
2016-03-03 07:00
lintcode
-easy-Nth to Last Node in List Show result
Findthenthtolastelementofasinglylinkedlist. Theminimumnumberofnodesinlistisn.GivenaList 3->2->1->5->nullandn=2,returnnode whosevalueis1. /** *DefinitionforListNode. *publicclassListNode{ *intval;
哥布林工程师
·
2016-03-03 07:00
lintcode
-easy-Minimum Subarray
Givenanarrayofintegers,findthesubarraywithsmallestsum.Returnthesumofthesubarray.For [1,-1,-2,1],return -3 这道题就是把MaximumSubarray反过来写一下publicclassSolution{ /** *@paramnums:alistofintegers *@return:Ai
哥布林工程师
·
2016-03-03 07:00
lintcode
-easy-Minimum Path Sum
Givena m x n gridfilledwithnon-negativenumbers,findapathfromtoplefttobottomrightwhich minimizes thesumofallnumbersalongitspath. 动态规划,比较直接,不多说了publicclassSolution{ /** *@paramgrid:alistoflistsofinteg
哥布林工程师
·
2016-03-03 07:00
lintcode
-【中等】恢复IP地址
题目给一个由数字组成的字符串。求出其可能恢复为的所有IP地址。链接。样例给出字符串 "25525511135",所有可能的IP地址为:["255.255.11.135","255.255.111.35"]答案直接暴力遍历就行了,只不过需要注意的是0,以及数字是不能有前缀0。代码1classSolution{ 2private: 3intstrToInt(conststring&str) 4{
Shirlies
·
2016-02-29 20:00
九度-题目1202:排序 对输入的n个数进行排序并输出
闲来无事,做点题打发打发时间,在九度上从前到后按照难易度来做,一道排序题,用了sort函数,算是投机取巧,不过对于小题应该可以,练练题,虽然巨简单,不过摆正态度,一题一题来,(直接做
lintcode
和了
cjt5047
·
2016-02-25 14:15
研究生复试机试练习
【
Lintcode
】LRU Cache, Data Stream Median
主要是priority_queue的用法一个是内置类型优先队列怎么设置小根堆(默认大根堆)如果是自定义数据结构,有两种办法1、定义这种数据结构的比较符号,就可以当成内置类型整2、传进去一个重载()的类,当小于号用,默认还是大根堆,也许传进去的是个callableobject都行的吧,我试了一下函数好像不行,不懂,不管了LRUCacheclassLRUCache{ public: //@para
syb3181
·
2016-02-21 21:00
lintcode
二进制求和 给定两个二进制字符串,返回他们的和(用二进制表示)。
Lintcode
容易题二进制求和查看运行结果15:00Start给定两个二进制字符串,返回他们的和(用二进制表示)。您在真实的面试中是否遇到过这个题?
cjt5047
·
2016-02-21 18:58
lintcode
-easy-Binary Tree Paths
Givenabinarytree,returnallroot-to-leafpaths. 这道题主要利用一下java的一个特性,String是immutable的对象,不能修改,只能重新生成/** *DefinitionofTreeNode: *publicclassTreeNode{ *publicintval; *publicTreeNodeleft,right; *publicT
哥布林工程师
·
2016-02-21 11:00
lintcode
-easy-Binary Tree Inorder Traversal
Givenabinarytree,returnthe inorder traversalofitsnodes'values.ExampleGivenbinarytree {1,#,2,3},1 \ 2 / 3 return [1,3,2].ChallengeCanyoudoitwithoutrecursion?两种做法:1.使用递归,思路比较直接,不多说了/** *Definitio
哥布林工程师
·
2016-02-21 11:00
lintcode
-easy-Add two numbers
Youhavetwonumbersrepresentedbyalinkedlist,whereeachnodecontainsasingledigit.Thedigitsarestoredin reverse order,suchthatthe1'sdigitisattheheadofthelist.Writeafunctionthataddsthetwonumbersandreturnsthes
哥布林工程师
·
2016-02-21 10:00
【
Lintcode
】Median of two Sorted Arrays
classSolution{ public: /** *@paramA:Anintegerarray. *@paramB:Anintegerarray. *@return:adoublewhoseformatis*.5or*.0 */ intcheck(vector&A,vector&B,intk,intm) { intM=A.size(); intN=B.size()
syb3181
·
2016-02-20 14:00
【
Lintcode
】Building Outline
classSolution{ public: /** *@parambuildings:Alistoflistsofintegers *@return:Findtheoutlineofthosebuildings */ setloc; map>st,en; multisetH; vector>buildingOutline(vector>&buildings)
syb3181
·
2016-02-19 20:00
lintcode
-easy-Add Binary
Giventwobinarystrings,returntheirsum(alsoabinarystring). Examplea= 11b= 1Return 100 这道题也没太多好说的……publicclassSolution{ /** *@paramaanumber *@parambanumber *@returntheresult */ publicStringaddBinar
哥布林工程师
·
2016-02-18 17:00
lintcode
刷题 A + B 问题 位运算
A+B问题15:00Start给出两个整数a和b,求他们的和,但不能使用+等数学运算符。您在真实的面试中是否遇到过这个题?Yes样例如果a=1并且b=2,返回3注意你不需要从输入流读入数据,只需要根据aplusb的两个参数a和b,计算他们的和并返回就行。挑战显然你可以直接returna+b,但是你是否可以挑战一下不这样做?说明a和b都是32位整数么?是的我可以使用位运算符么?当然可以思路:考虑一个
cjt5047
·
2016-02-18 15:26
lintcode
-easy-A+B problem
WriteafunctionthataddtwonumbersAandB.Youshouldnotuse + oranyarithmeticoperators.ExampleGiven a=1 and b=2 return 3NoteThereisnoneedtoreaddatafromstandardinputstream.Bothparametersaregiveninfunction apl
哥布林工程师
·
2016-02-18 13:00
lintcode
-easy-Remove Linked List Elements
Removeallelementsfromalinkedlistofintegersthathavevalue val. ExampleGiven 1->2->3->3->4->5->3,val=3,youshouldreturnthelistas1->2->4->5 看起来这题不难,但是还是有些地方需要注意,据说面试要做到bug-free p=p.next;执行之后,p有可能是null,所以在循
哥布林工程师
·
2016-02-18 13:00
lintcode
-easy-Fibonacci
Findthe NthnumberinFibonaccisequence.AFibonaccisequenceisdefinedasfollow:Thefirsttwonumbersare0and1.The i thnumberisthesumof i-1thnumberand i-2thnumber.ThefirsttennumbersinFibonaccisequenceis:0,1,1,2,
哥布林工程师
·
2016-02-18 12:00
lintcode
第一天
到了学校开始刷刷题,比如
lintcode
,leetcode,这两个真蛋疼,起这种名字。感觉面试的题目还都挺简单的,就是要又快又好的写好我还做不到。不是为了找工作真是懒得写这些破题的。
syb3181
·
2016-02-17 14:00
[
LintCode
] Max Points on a Line
ProblemGivennpointsona2Dplane,findthemaximumnumberofpointsthatlieonthesamestraightline.ExampleGiven4points:(1,2),(3,6),(0,0),(1,3).Themaximumnumberis3.Note建立一个斜率对应point个数的HashMap。两次循环对points中第i个和第j个进行
linspiration
·
2016-02-16 00:00
point
mathematics
hashtable
hash
java
LintCode
: 生成括号
生成括号给定n对括号,请写一个函数以将其生成新的括号组合,并返回所有组合结果。您在真实的面试中是否遇到过这个题?Yes样例给定n=3,可生成的组合如下:"((()))","(()())","(())()","()(())","()()()"标签Expand相关题目ExpandTimerExpand解题思路:采用递归树的思想,当左括号数大于右括号数时可以加左或者右括号,否则只能加左括号,当左括号数达
cumt_cx
·
2016-02-15 10:28
LintCode
Subtree
原题链接在这里:http://www.
lintcode
.com/en/problem/subtree/Youhavetwoeverylargebinarytrees: T1,withmillionsofnodes
Dylan_Java_NYC
·
2016-02-13 23:00
[
LintCode
/LeetCode] Min Stack/Max Stack
ProblemImplementastackwithmin()function,whichwillreturnthesmallestnumberinthestack.Itshouldsupportpush,popandminoperationallinO(1)cost.Examplepush(1)pop()//return1push(2)push(3)min()//return2push(1)mi
linspiration
·
2016-02-11 00:00
java
stack
amazon
设计
[
LintCode
] strStr [KMP & brute force]
ProblemForagivensourcestringandatargetstring,youshouldoutputthefirstindex(from0)oftargetstringinsourcestring.Iftargetdoesnotexistinsource,justreturn-1.Note我终于找到了比较好的KMP算法。http://alice-alicesspace.blog
linspiration
·
2016-02-11 00:00
string
java
basic
[
LintCode
/LeetCode] Binary Tree Serialization
ProblemDesignanalgorithmandwritecodetoserializeanddeserializeabinarytree.Writingthetreetoafileiscalled'serialization'andreadingbackfromthefiletoreconstructtheexactsamebinarytreeis'deserialization'.The
linspiration
·
2016-02-10 00:00
interesting
serialization
binary-tree
java
Lintcode
: Subtree
Youhavetwoeverylargebinarytrees:T1,withmillionsofnodes,andT2,withhundredsofnodes.CreateanalgorithmtodecideifT2isasubtreeofT1. Haveyoumetthisquestioninarealinterview?Yes Example T2isasubtreeofT1in
neverlandly
·
2016-02-08 23:00
一些OJ网站
https://leetcode.com/http://www.
lintcode
.com/http://www.spoj.com/http://www.hihocoder.com/problemsethttp
hotea
·
2016-02-03 19:00
OJ
[
LintCode
] Swap Nodes in Pairs
ProblemGivenalinkedlist,swapeverytwoadjacentnodesandreturnitshead.ExampleGiven1->2->3->4,youshouldreturnthelistas2->1->4->3.Note指针为p,我们选择swap的两个结点是p.next和p.next.next。要注意while循环的边界条件,这两个结点不能为空。主要思路是先用n
linspiration
·
2016-02-03 00:00
linkedlist
java
swap
链表
Lintcode
: Expression Evaluation (Basic Calculator III)
Givenanexpressionstringarray,returnthefinalresultofthisexpression Haveyoumetthisquestioninarealinterview?Yes Example Fortheexpression2*6-(23+7)/(1+2), inputis [ "2","*","6","-","(", "23","+
neverlandly
·
2016-02-02 13:00
Lintcode
: Count of Smaller Number
Giveyouanintegerarray(indexfrom0ton-1,wherenisthesizeofthisarray,valuefrom0to10000)andanquerylist.Foreachquery,giveyouaninteger,returnthenumberofelementinthearraythataresmallerthanthegiveninteger.
neverlandly
·
2016-02-02 07:00
Lintcode
: Interval Sum II
Givenanintegerarrayintheconstructmethod,implementtwomethodsquery(start,end)andmodify(index,value): Forquery(start,end),returnthesumfromindexstarttoindexendinthegivenarray. Formodify(index,value),m
neverlandly
·
2016-02-02 05:00
Lintcode
: Interval Sum
Givenanintegerarray(indexfrom0ton-1,wherenisthesizeofthisarray),andanquerylist.Eachqueryhastwointegers[start,end].Foreachquery,calculatethesumnumberbetweenindexstartandendinthegivenarray,returntheresu
neverlandly
·
2016-02-02 04:00
[
LintCode
/LeetCode] Generate Parentheses
ProblemGivennpairsofparentheses,writeafunctiontogenerateallcombinationsofwell-formedparentheses.ExampleGivenn=3,asolutionsetis:"((()))","(()())","(())()","()(())","()()()"NoteBytheway,Symbolmeaning/tn
linspiration
·
2016-02-02 00:00
zenefits
string
递归
backtracking
recursion
[LeetCode/
LintCode
] Binary Tree Paths
ProblemGivenabinarytree,returnallroot-to-leafpaths.ExampleGiventhefollowingbinarytree:1/\23\5Allroot-to-leafpathsare:["1->2->5","1->3"]SolutionpublicclassSolution{publicListbinaryTreePaths(TreeNoderoo
linspiration
·
2016-02-02 00:00
leetcode
binary-tree
二叉树
遍历
facebook
Lintcode
: Interval Minimum Number
Givenanintegerarray(indexfrom0ton-1,wherenisthesizeofthisarray),andanquerylist.Eachqueryhastwointegers[start,end].Foreachquery,calculatetheminimumnumberbetweenindexstartandendinthegivenarray,returnthe
neverlandly
·
2016-02-01 12:00
Lintcode
: Segment Tree Query II
Foranarray,wecanbuildaSegmentTreeforit,eachnodestoresanextraattributecounttodenotethenumberofelementsinthethearraywhichvalueisbetweenintervalstartandend.(Thearraymaynotfullyfilledbyelements) Design
neverlandly
·
2016-02-01 11:00
Lintcode
: Segment Tree Modify
ForaMaximumSegmentTree,whicheachnodehasanextravaluemaxtostorethemaximumvalueinthisnode'sinterval. Implementamodifyfunctionwiththreeparameterroot,indexandvaluetochangethenode'svaluewith[start,end]=[
neverlandly
·
2016-02-01 08:00
Lintcode
: Segment Tree Query
Foranintegerarray(indexfrom0ton-1,wherenisthesizeofthisarray),inthecorrespondingSegmentTree,eachnodestoresanextraattributemaxtodenotethemaximumnumberintheintervalofthearray(indexfromstarttoend). De
neverlandly
·
2016-02-01 07:00
Lintcode
: Segment Tree Build
ThestructureofSegmentTreeisabinarytreewhicheachnodehastwoattributesstartandenddenoteansegment/interval. startandendarebothintegers,theyshouldbeassignedinfollowingrules: Theroot'sstartandendisgiv
neverlandly
·
2016-02-01 06:00
Lintcode
: Matrix Zigzag Traversal
Givenamatrixofmxnelements(mrows,ncolumns),returnallelementsofthematrixinZigZag-order. Haveyoumetthisquestioninarealinterview?Yes Example Givenamatrix: [ [1,2,3,4], [5,6,7,8], [9,10,11,12]
neverlandly
·
2016-02-01 05:00
[OJ] Lowest Common Ancestor
LintCode
88.LowestCommonAncestor(Medium)LeetCode236.LowestCommonAncestorofaBinaryTree(Medium)今天写了三种解法,
lzl124631x
·
2016-01-30 15:00
Lintcode
: 统计数字
统计数字计算数字k在0到n中的出现的次数,k可能是0~9的一个值您在真实的面试中是否遇到过这个题?Yes样例例如n=12,k=1,在[0,1,2,3,4,5,6,7,8,9,10,11,12],我们发现1出现了5次(1,10,11,12)标签Expand相关题目ExpandTimerExpand当某一位的数字小于i时,那么该位出现i的次数为:更高位数字x当前位数当某一位的数字等于i时,那么该位出现
cumt_cx
·
2016-01-29 15:48
LintCode
算法
面试
[OJ] Search for a Range
LintCode
61.SearchforaRange(Medium)LeetCode34.SearchforaRange(Medium)classSolution{ private: intfindBound
lzl124631x
·
2016-01-28 20:00
上一页
71
72
73
74
75
76
77
78
下一页
按字母分类:
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
其他