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
空格替换
设计一种方法,将一个字符串中的所有空格替换成%20。你可以假设该字符串有足够的空间来加入新的字符,且你得到的是“真实的”字符长度。你的程序还需要返回被替换后的字符串的长度。样例对于字符串"MrJohnSmith",长度为13替换空格之后,参数中的字符串需要变为"Mr%20John%20Smith",并且把新长度17作为结果返回。publicclassSolution{/***@paramstrin
六尺帐篷
·
2020-02-23 06:52
LintCode
- 反转整数(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:将一个整数中的数字进行颠倒,当颠倒后的整数溢出时,返回0(标记为32位整数)。样例给定x=123,返回321给定x=-123,返回-321思路:通过对数字模十取余得到它的最低位。其实本题考查的是整数相加的溢出处理,检查溢出有这么几种办法:两个正数数相加得到负数,或者两个负数相加得到正数,但某些编译器溢出优化的方式不一样对于正数,如
柒黍
·
2020-02-23 03:58
Lintcode
110 Minimum Path Sum solution 题解
【题目描述】Givenamxngridfilledwithnon-negativenumbers,findapathfromtoplefttobottomrightwhichminimizesthesumofallnumbersalongitspath.给定一个只含非负整数的m*n网格,找到一条从左上角到右下角的可以使数字和最小的路径。【注】:你在同一时间只能向下或者向右移动一步【题目链接】www
程风破浪会有时
·
2020-02-23 03:16
OJ
lintcode
爬楼梯
假设你正在爬楼梯,需要n步你才能到达顶部。但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部?假设你正在爬楼梯,需要n步你才能到达顶部。但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部?/*这道题目的思路是动态规划上n个台阶有多少中可能?f(n)=f(n-1)+f(n-2)那么很显然,到达最后一个台阶的方法数目等于前一个台阶的方法数目加上前两个台阶的方法数目,到这里我们发现这
zhaozhengcoder
·
2020-02-23 02:06
Recover Binary Search Tree
https://www.
lintcode
.com/problem/recover-binary-search-tree/description/***DefinitionofTreeNode:*publicclassTreeNode
天街孤独
·
2020-02-23 01:21
LintCode
- 二叉树的所有路径(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:给一棵二叉树,找出从根节点到叶子节点的所有路径。样例给出下面这棵二叉树:1/\23\5所有根到叶子的路径为:["1->2->5","1->3"]/***DefinitionofTreeNode:*publicclassTreeNode{*publicintval;*publicTreeNodeleft,right;*publicT
柒黍
·
2020-02-22 17:13
Lintcode
43 Maximum Subarray III solution 题解
【题目描述】Givenanarrayofintegersandanumberk,findknon-overlappingsubarrayswhichhavethelargestsum.Thenumberineachsubarrayshouldbecontiguous.Returnthelargestsum.Notice:Thesubarrayshouldcontainatleastonenumbe
代码码着玩
·
2020-02-22 15:03
[
LintCode
][System Design] Consistent Hashing
Problem一般的数据库进行horizontalshard的方法是指,把id对数据库服务器总数n取模,然后来得到他在哪台机器上。这种方法的缺点是,当数据继续增加,我们需要增加数据库服务器,将n变为n+1时,几乎所有的数据都要移动,这就造成了不consistent。为了减少这种naive的hash方法(%n)带来的缺陷,出现了一种新的hash算法:一致性哈希的算法——ConsistentHashi
楷书
·
2020-02-22 10:44
Lintcode
156 Merge Intervals solution 题解
【题目链接】www.
lintcode
.com/en/problem/merge-intervals/【题目解析】此题可先将目标区间数组按X轴从小到大排序。
程风破浪会有时
·
2020-02-22 09:17
Longest Common Subsequence(最长公共子序列)
http://www.
lintcode
.com/zh-cn/problem/longest-common-subsequence/publicclassSolution{/**@paramA:Astring
天街孤独
·
2020-02-22 06:03
LintCode
495 [Implement Stack]
原题实现一个栈,可以使用除了栈之外的数据结构样例push(1)pop()push(2)top()//return2pop()isEmpty()//returntruepush(3)isEmpty()//returnfalse解题思路使用pythonlist实现stack数据结构完整代码classStack:#initializeyourdatastructurehere.def__init__(s
Jason_Yuan
·
2020-02-22 04:49
Maximum Product of Three Numbers
https://www.
lintcode
.com/problem/maximum-product-of-three-numbers/descriptionimportjava.util.Arrays;publicclassSolution
天街孤独
·
2020-02-22 01:13
LintCode
-488.快乐数
题目描述写一个算法来判断一个数是不是"快乐数"。一个数是不是快乐是这么定义的:对于一个正整数,每一次将该数替换为他每个位置上的数字的平方和,然后重复这个过程直到这个数变为1,或是无限循环但始终变不到1。如果可以变为1,那么这个数就是快乐数。样例19就是一个快乐数。1^2+9^2=828^2+2^2=686^2+8^2=1001^2+0^2+0^2=1解答思路计算过程中的数字都存在Set中,如果后续
悠扬前奏
·
2020-02-22 00:05
LintCode
排列序号
题目给出一个不含重复数字的排列,求这些数字的所有排列按字典序排序后该排列的编号。其中,编号从1开始。样例例如,排列[1,2,4]是第1个排列。分析1.对于四位数:4213=4100+2100+110+32.4个数的排列有4!种。当我们知道第一位数的时候,还有3!种方式,当知道第二位数时候还有2!种方式,当知道第三位数的时候还有1!种方式,前面三位数都确定的时候,最后一位也确定了。3.对4个数的排列
六尺帐篷
·
2020-02-21 16:54
LintCode
搜索旋转排序数组
题目假设有一个排序的按未知的旋转轴旋转的数组(比如,0124567可能成为4567012)。给定一个目标值进行搜索,如果在数组中找到目标值返回数组中的索引位置,否则返回-1。你可以假设数组中不存在重复的元素。样例给出[4,5,1,2,3]和target=1,返回2给出[4,5,1,2,3]和target=0,返回-1分析代码publicclassSolution{/***@paramA:anint
六尺帐篷
·
2020-02-21 16:44
矩形
https://www.
lintcode
.com/problem/rectangle/description/*publicclassPoint{publicintx;publicinty;publicPoint
天街孤独
·
2020-02-21 15:14
Lintcode
245 Subtree solution 题解
【题目描述】Youhavetwoeverylargebinarytrees:T1,withmillionsofnodes,andT2,withhundredsofnodes.CreateanalgorithmtodecideifT2isasubtreeofT1.Notice:AtreeT2isasubtreeofT1ifthereexistsanodeninT1suchthatthesubtree
程风破浪会有时
·
2020-02-21 13:29
lintcode
166 删除链表倒数第n个数
image.png/***DefinitionforListNode.*publicclassListNode{*intval;*ListNodenext;*ListNode(intval){*this.val=val;*this.next=null;*}*}*/publicclassSolution{/***@paramhead:Thefirstnodeoflinkedlist.*@paramn
jose_dl
·
2020-02-21 09:29
Course Schedule III
http://www.
lintcode
.com/zh-cn/problem/course-schedule-iii/packagecom.
LintCode
.CourseSchedule3;importjava.util.Arrays
天街孤独
·
2020-02-21 08:56
Maximum Subarray III(最大子数组 III)
http://www.
lintcode
.com/en/problem/maximum-subarray-iii/?
天街孤独
·
2020-02-21 07:07
Lintcode
157 Unique Characters solution 题解
【题目链接】www.
lintcode
.com/en/problem/unique-characters/【题目解析】可以用HashMap或者数组来记录字符是否已经出现过,由于本题无须获取重复字符的个数,
程风破浪会有时
·
2020-02-20 23:11
Beautiful Arrangement II
https://www.
lintcode
.com/problem/beautiful-arrangement-ii/descriptionpublicclassSolution{/***@paramn:
天街孤独
·
2020-02-20 23:15
入门系列-记录几个可以刷题的网站
1、
LintCode
LintCode
网站是国内较大的在线编程&测评网站。
qq_38213675
·
2020-02-20 22:04
最高频的K个单词
http://www.
lintcode
.com/zh-cn/problem/top-k-frequent-words/importjava.util.ArrayList;importjava.util.Collections
天街孤独
·
2020-02-20 21:37
[
Lintcode
][java]回文数
判断一个正整数是不是回文数。样例11,121,1,12321这些是回文数。23,32,1232这些不是回文数。publicclassSolution{/**@paramnum:apositivenumber*@return:trueifit'sapalindromeorfalse*/publicbooleanisPalindrome(intnum){//writeyourcodehereinta=
第六象限
·
2020-02-20 15:31
Lintcode
115 Unique Paths || solution 题解
【题目描述】Followupfor"UniquePaths":Nowconsiderifsomeobstaclesareaddedtothegrids.Howmanyuniquepathswouldtherebe?Anobstacleandemptyspaceismarkedas1and0respectivelyinthegrid."不同的路径"的跟进问题:现在考虑网格中有障碍物,那样将会有多少条
程风破浪会有时
·
2020-02-20 09:36
LintCode
- 有效的括号序列(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:给定一个字符串所表示的括号序列,包含以下字符:'(',')','{','}','['and']',判定是否是有效的括号序列。样例括号必须依照"()"顺序表示,"()[]{}"是有效的括号,但"([)]"则是无效的括号。思路:/***@paramsAstring*@returnwhetherthestringisavalidpare
柒黍
·
2020-02-20 09:07
LintCode
- 丑数(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:写一个程序来检测一个整数是不是丑数。丑数的定义是,只包含质因子2,3,5的正整数。比如6,8就是丑数,但是14不是丑数以为他包含了质因子7。样例给出num=8,返回true。给出num=14,返回false。思路:/***@paramnumaninteger*@returntrueifnumisanuglynumberorfals
柒黍
·
2020-02-20 08:37
LintCode
380. Intersection of Two Linked Lists
題目:Writeaprogramtofindthenodeatwhichtheintersectionoftwosinglylinkedlistsbegins.NoticeIfthetwolinkedlistshavenointersectionatall,returnnull.Thelinkedlistsmustretaintheiroriginalstructureafterthefuncti
aammyytt
·
2020-02-20 07:53
Nth to Last Node in List
NthtoLastNodeinList今天是一道简单的题目,来自
LintCode
,难度为Easy,Acceptance为40%。
ab409
·
2020-02-20 04:03
Array Nesting
https://www.
lintcode
.com/problem/array-nesting/descriptionimportjava.util.ArrayList;importjava.util.HashSet
天街孤独
·
2020-02-20 01:46
LintCode
- 链表求和(容易)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:假定用一个链表表示两个数,其中每个节点仅包含一个数字。假设这两个数的数字顺序排列,请设计一种方法将两个数相加,并将其结果表现为链表的形式。样例给出两个链表3->1->5->null和5->9->2->null,返回8->0->8->null思路:解题容易,注意边界处理。/***Definitionforsingly-linkedl
柒黍
·
2020-02-20 01:36
乘积最大子序列
LintCode
题目地址找出一个序列中乘积最大的连续子序列(至少包含一个数)。
只为此心无垠
·
2020-02-19 22:30
OJ
lintcode
落单的数
给出2*n+1个的数字,除其中一个数字之外其他每个数字均出现两次,找到这个数字。您在真实的面试中是否遇到过这个题?Yes样例给出[1,2,2,1,3,4,3],返回4classSolution{public:/***@paramA:Arrayofintegers.*return:Thesinglenumber.*/intsingleNumber(vector&A){//writeyourcodeh
zhaozhengcoder
·
2020-02-19 20:08
GOOGLE SDE 面经
1.
LintCode
-寻找峰值。给定一个无重复整数的数组,首先增加然后减少。查找其中的最大数字。
程风破浪会有时
·
2020-02-19 20:01
Longest Increasing Subsequence(最长上升子序列)
http://www.
lintcode
.com/en/problem/longest-increasing-subsequence/?
天街孤独
·
2020-02-19 19:08
二分搜索解题
lintcode
:(60)SearchInsertPositionProblemStatementGivenasortedarrayandatargetvalue,returntheindexifthetargetisfound.Ifnot
crazydane
·
2020-02-19 17:32
LintCode
627 Longest Palindrome
題目:Givenastringwhichconsistsoflowercaseoruppercaseletters,findthelengthofthelongestpalindromesthatcanbebuiltwiththoseletters.Thisiscasesensitive,forexample"Aa"isnotconsideredapalindromehere.思路:這一題如果只要
aammyytt
·
2020-02-19 12:30
lintcode
两个排序数组的中位数
给出数组A=[1,2,3,4,5,6]B=[2,3,4,5],中位数3.5给出数组A=[1,2,3]B=[4,5],中位数3题目链接:http://www.
lintcode
.com/zh-cn/problem
yzawyx0220
·
2020-02-19 09:58
LintCode
166 [Nth to Last Node in List]
原题找到单链表倒数第n个节点,保证链表中节点的最少数量为n。样例给出链表**3->2->1->5->null**和n=2,返回倒数第二个节点的值1.解题思路快慢指针,快指针先走n步�,然后快慢指针一起同步速走,快指针走到头,慢指针即为所求完整代码"""DefinitionofListNodeclassListNode(object):def__init__(self,val,next=None):
Jason_Yuan
·
2020-02-19 09:01
lintcode
112 删除链表中重复元素,留下一个
思路要考虑到有可能重复的元素有很多个,因此下面代码不正确/***DefinitionforListNode*publicclassListNode{*intval;*ListNodenext;*ListNode(intx){*val=x;*next=null;*}*}*/publicclassSolution{/***@paramListNodeheadistheheadofthelinkedli
jose_dl
·
2020-02-19 09:53
lintcode
73:前序遍历和中序遍历树构造二叉树
题目描述根据前序遍历和中序遍历树构造二叉树.样例给出中序遍历:[1,2,3]和前序遍历:[2,1,3].返回如下的树:2/\13思路先序遍历的第一个数为根值,在中序遍历的数组中找到该值,并则在该值左边为其左子树,右边为其右子树。实现/***@parampreorder:树的先序遍历列表*@paraminorder:树的中序遍历列表*@return:Rootofatree*//**使用先序遍历和中序
狸猫副园长
·
2020-02-19 07:35
Word Break(单词切分)
YesExampleGivens="
lintcode
",dict=["lint","c
天街孤独
·
2020-02-19 06:30
LintCode
365. Count 1 in Binary
原题
LintCode
365.Count1inBinaryDescriptionCounthowmany1inbinaryrepresentationofa32-bitinteger.ExampleGiven32
Andiedie
·
2020-02-19 05:59
[
LintCode
][DFS] Find the Connected Component in the Undirected Graph
ProblemFindthenumberconnectedcomponentintheundirectedgraph.Eachnodeinthegraphcontainsalabelandalistofitsneighbors.(aconnectedcomponent(orjustcomponent)ofanundirectedgraphisasubgraphinwhichanytwovertic
楷书
·
2020-02-19 04:57
LintCode
57. 三数之和
原题解第一步,万年不变的查错。如果给的array是null或不够三个数,直接return空的result。因为returntype是list,一般情况下绝不returnnull,而是returnemptylist。publicList>threeSum(int[]nums){List>results=newArrayList>results){....}因为array已经排好序了,所以左右同时进行
Jay_8d33
·
2020-02-19 04:18
Lintcode
36 Reverse Linked List II solution 题解
nsatisfythefollowingcondition:1≤m≤n≤lengthoflist.翻转链表中第m个节点到第n个节点的部分注意:m,n满足1≤m≤n≤链表长度【题目链接】http://www.
lintcode
.com
代码码着玩
·
2020-02-19 03:52
LintCode
二叉树的所有路径
题目给一棵二叉树,找出从根节点到叶子节点的所有路径。样例给出下面这棵二叉树:binaryTree1.PNG所有根到叶子的路径为:binaryTree2.PNG分析显然本道题可以使用递归算法。每天路径结束的条件的是遇到叶子节点,该树有多少个叶子节点就会有多少路径。分别递归求解左子树和右子树。代码/***DefinitionofTreeNode:*publicclassTreeNode{*public
六尺帐篷
·
2020-02-19 01:15
Lintcode
5 Kth Largest Element solution 题解
FindK-thlargestelementinanarray.Notice:Youcanswapelementsinthearray在数组中找到第k大的元素注意:你可以交换数组中的元素的位置【题目链接】http://www.
lintcode
.com
代码码着玩
·
2020-02-19 00:56
OJ
lintcode
最大子数组
给定一个整数数组,找到一个具有最大和的子数组,返回其最大和。注意事项子数组最少包含一个数您在真实的面试中是否遇到过这个题?Yes样例给出数组[−2,2,−3,4,−1,2,1,−5,3],符合要求的子数组为[4,−1,2,1],其最大和为6classSolution{public:/***@paramnums:Alistofintegers*@return:Aintegerindicatethes
zhaozhengcoder
·
2020-02-18 23:31
上一页
45
46
47
48
49
50
51
52
下一页
按字母分类:
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
其他