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
-乘积最大子序列
找出一个序列中乘积最大的连续子序列(至少包含一个数)。样例比如,序列 [2,3,-2,4] 中乘积最大的子序列为 [2,3] ,其乘积为6。分析:访问到每个点的时候,以该点为子序列的末尾的乘积,要么是该点本身,要么是该点乘以以前一点为末尾的序列,注意乘积负负得正,故需要记录前面的最大最小值。代码:classSolution{ public: /** *@paramnums:avectorofint
wangyuquanliuli
·
2015-05-15 21:00
面试
lintcode
LintCode
-丢失的第一个正整数
给出一个无序的正数数组,找出其中没有出现的最小正整数。样例如果给出 [1,2,0],return 3 如果给出 [3,4,-1,1],return 2挑战只允许时间复杂度O(n)的算法,并且只能使用常数级别的空间。分析:把当前数放到该放的位置即可,如1应该放到第0个位置,2应该放到第1个位置。代码:classSolution{ public: /** *@paramA:avectorofinteg
wangyuquanliuli
·
2015-05-15 20:00
面试
lintcode
LintCode
-接雨水
给出 n 个非负整数,代表一张X轴上每个区域宽度为 1 的海拔图,计算这个海拔图最多能接住多少(面积)雨水。样例如上图所示,海拔分别为 [0,1,0,2,1,0,1,3,2,1,2,1],返回 6.挑战O(n)时间,O(1)空间O(n)时间,O(n)空间也可以接受分析:只能遍历一遍,且不能存储所有的高度,一块直柱能接的水取决于左右两边较短的高度,所以一个比较直观的方法是从左到有遍历一遍记录该点左边
wangyuquanliuli
·
2015-05-15 12:00
面试
lintcode
LintCode
-第k个排列
给定 n 和 k,求123..n组成的排列中的第 k 个排列。样例对于 n=3,所有的排列如下:123 132 213 231 312 321 如果 k=4,第4个排列为,231.注意1≤n≤9分析:可以提前计算好不同的k个数有多少个排列,然后一位一位的确定,比如n=3,k=3的情况下,要确立第一位的时候,后面两个数可以产生2个不同的排列,那么第一位肯定应该是2,如果是1的话,k最多为2,如果是3
wangyuquanliuli
·
2015-05-14 22:00
面试
lintcode
LintCode
-统计比给定整数小的数的个数
给定一个整数数组(下标由0到n-1,其中n表示数组的规模,数值范围由0到10000),以及一个查询列表。对于每一个查询,将会给你一个整数,请你返回该数组中小于给定整数的元素的数量。样例对于数组 [1,2,7,8,5] ,查询 [1,8,5],返回 [0,4,2]注意在做此题前,最好先完成 线段树的构造 and 线段树查询II 这两道题目。挑战可否用一下三种方法完成以上题目。仅用循环方法分类搜索和二
wangyuquanliuli
·
2015-05-14 19:00
面试
lintcode
LintCode
-最多有k个不同字符的最长子字符串
给定一个字符串,找到最多有k个不同字符的最长子字符串。样例例如,给定s= "eceba" , k=3,T是 "eceb",长度为 4.挑战O(n),n是所给字符串的长度分析:采用双指针,用map记录双指针中间的字符串是否满足要求代码:classSolution{ public: /** *@params:Astring *@return:Thelengthofthelongestsubstring
wangyuquanliuli
·
2015-05-14 19:00
面试
lintcode
LintCode
-最小差
给定两个整数数组(第一个是数组 A,第二个是数组 B),在数组A中取A[i],数组B中取B[j],A[i]和B[j]两者的差越小越好(|A[i]-B[j]|)。返回最小差。样例给定数组A= [3,4,6,7],B= [2,3,8,9],返回 0。挑战时间复杂度O(n log n)分析:看到时间复杂度就想到遍历A数组然后对B数组进行二分查找,二分查找可以手写,也可以直接调用STL。代码:classS
wangyuquanliuli
·
2015-05-14 19:00
面试
lintcode
LintCode
-数飞机
给出飞机的起飞和降落时间的列表,用interval序列表示.请计算出天上同时最多有多少架飞机?样例对于每架飞机的起降时间列表:[[1,10],[2,3],[5,8],[4,7]],返回3。注意如果多架飞机降落和起飞在同一时刻,我们认为降落有优先权。分析:可以根据每个线段,利用一个map来标记,对于第一个[1,10],我们标记m[1]+=1,m[10]-=1,表示在1这个时刻多了一架飞机,而在10这
wangyuquanliuli
·
2015-05-14 19:00
面试
lintcode
LintCode
-最长无重复字符的子串
给定一个字符串,请找出其中无重复字符的最长子字符串。样例例如,在"abcabcbb"中,其无重复字符的最长子字符串是"abc",其长度为 3。对于,"bbbbb",其无重复字符的最长子字符串为"b",长度为1。挑战O(n)时间分析:遍历该字符串,每遍历一个字母时,利用map去找该字母最近一次出现是什么时候,中间这一段便是无重复字符的字符串。代码:classSolution{ public: /**
wangyuquanliuli
·
2015-05-14 19:00
面试
lintcode
LintCode
-装最多水的容器
给定 n 个非负整数a1,a2,...,an,每个数代表了坐标中的一个点 (i,ai)。画 n 条垂直线,使得 i 垂直线的两个端点分别为(i,ai)和(i,0)。找到两条线,使得其与 x 轴共同构成一个容器,以容纳最多水。样例给出[1,3,2],最大的储水面积是2.注意容器不可倾斜。分析:采用两边逼近法,显而易见,当逐渐逼近的时候,容器的长在变短,那么要使得面积增大的话,宽必须要变大,所以我们保
wangyuquanliuli
·
2015-05-14 19:00
面试
lintcode
[
LintCode
] 寻找缺失的数
1 class Solution { 2 public: 3 /** 4 * @param nums: a vector of integers 5 * @return: an integer 6 */ 7 int findMissing(vector<int> &nums) { 8
·
2015-05-13 16:00
code
九章算法面试题68 4 sum
在线测试本题http://www.
lintcode
.com/en/problem/4-sum/解答方法一:这道题的方法也非常类似2sum的第二种解法。
九章算法
·
2015-05-13 02:36
九章算法面试题
九章算法面试题66 2 sum
在线测试本题http://www.
lintcode
.com/en/problem/2-sum/解答如果原题的数组中第i个元素我们用ai来表示,目标值我们用v来表示。
九章算法
·
2015-05-13 02:04
两根指针
leetcode
九章算法
lintcode
面试题
九章算法面试题
九章算法面试题65 拓扑排序
在线测试本题http://www.
lintcode
.com/en/problem/topological-sorting/解答【背景知识】拓扑排序问题在我们生产工序或者是建立依赖关系当中有重要的运用。
九章算法
·
2015-05-13 02:50
图论
leetcode
九章算法
lintcode
面试题
九章算法面试题
九章算法面试题60 爬楼梯
在线测试本题http://www.
lintcode
.com/problem/climbin
九章算法
·
2015-05-13 02:00
九章算法面试题
九章算法面试题59 背包问题II
在线测试本题http://www.
lintcode
.com/en/problem/backpack-ii/解答设F[i][j]为前
九章算法
·
2015-05-13 02:04
九章算法面试题
lintcode
:Longest Substring with At Most K Distinct Characters
MediumLongestSubstringwithAtMostKDistinctCharactersShowresult26%AcceptedGivenastrings,findthelengthofthelongestsubstringTthatcontainsatmostkdistinctcharacters.ExampleForexample,Givens="eceba",k=3,Tis"
martin_liang
·
2015-05-11 21:47
算法
C++/C
lintcode
LintCode
第一题fizz buzz
【题目】给你一个整数n.从1到n按照下面的规则打印每个数:如果这个数被3整除,打印fizz如果这个数被5整除,打印buzz如果这个数能同时被3和5整除,打印fizzbuzz样例比如n=15,返回一个字符串数组:["1","2","fizz","4","buzz","fizz","7","8","fizz","buzz","11","fizz","13","14","fizzbuzz"]【C++代码
ryanscn
·
2015-03-14 23:31
vector
buzz
fizz
lintcode
LintCode
第一题fizz buzz
【题目】给你一个整数n.从1到n按照下面的规则打印每个数:如果这个数被3整除,打印fizz如果这个数被5整除,打印buzz如果这个数能同时被3和5整除,打印fizzbuzz样例比如n=15,返回一个字符串数组:["1","2","fizz","4","buzz","fizz","7","8","fizz","buzz","11","fizz","13","14","fizzbuzz"]【C++代码
ryanscn
·
2015-03-14 23:31
vector
lintcode
fizz
buzz
程序设计入门
[
LintCode
]k Sum II
题目Givennuniqueintegers,numberk(1>kSumII(intA[],intk,inttarget){ ArrayList>list=newArrayList>(); if(A.lengthl=newArrayList(); l.add(A[i]); list.add(l); returnlist; } }else{ int[]B=newint[A.length-i-1];
wankunde
·
2015-03-04 12:00
lintcode
K-Sum-II
[
LintCode
] First Bad Version
http://
lintcode
.com/en/problem/first-bad-version//** * public class VersionControl { * public static
furuijie8679
·
2015-01-15 03:03
interview
[
LintCode
] First Bad Version
http://
lintcode
.com/en/problem/first-bad-version//** * public class VersionControl { * public static
furuijie8679
·
2015-01-15 03:03
interview
Interview
[
LintCode
] Kth Prime Number
http://
lintcode
.com/en/problem/kth-prime-number/#class Solution { /** * @param k: The number
furuijie8679
·
2015-01-14 17:21
interview
[
LintCode
] Kth Prime Number
http://
lintcode
.com/en/problem/kth-prime-number/#class Solution { /** * @param k: The number k
furuijie8679
·
2015-01-14 17:21
interview
Interview
[
LintCode
] Compare Strings
http://
lintcode
.com/en/problem/compare-strings/public class Solution { /** * @param A : A string
furuijie8679
·
2015-01-14 15:14
interview
Interview
[
LintCode
] Compare Strings
http://
lintcode
.com/en/problem/compare-strings/public class Solution { /** * @param A : A string
furuijie8679
·
2015-01-14 15:14
interview
[
LintCode
] Rehashing
http://
lintcode
.com/en/problem/rehashing/#/** * Definition for ListNode * public class ListNode {
furuijie8679
·
2015-01-14 15:02
interview
[
LintCode
] Rehashing
http://
lintcode
.com/en/problem/rehashing/#/** * Definition for ListNode * public class ListNode { *
furuijie8679
·
2015-01-14 15:02
interview
Interview
[
LintCode
] Backpack II
http://
lintcode
.com/en/problem/backpack-ii/ public int backPackII(int m, int[] A, int V[]) {
furuijie8679
·
2015-01-12 06:49
LeetCode
[
LintCode
] Backpack II
http://
lintcode
.com/en/problem/backpack-ii/ public int backPackII(int m, int[] A, int V[]) {
furuijie8679
·
2015-01-12 06:49
LeetCode
Interview
[
LintCode
] Backpack
http://
lintcode
.com/en/problem/backpack/public class Solution { /** * @param m: An integer m
furuijie8679
·
2015-01-12 06:16
LeetCode
[
LintCode
] Backpack
http://
lintcode
.com/en/problem/backpack/public class Solution { /** * @param m: An integer m denotes
furuijie8679
·
2015-01-12 06:16
LeetCode
Interview
LintCode
-Minimum Path Sum
Givena m x n gridfilledwithnon-negativenumbers,findapathfromtoplefttobottomrightwhich minimizes thesumofallnumbersalongitspath.NoteYoucanonlymoveeitherdownorrightatanypointintime.Solution: 1publicclas
LiBlog
·
2015-01-09 08:00
LintCode
-Search for a Range
Givenasortedarrayofintegers,findthestartingandendingpositionofagiventargetvalue.Youralgorithm'sruntimecomplexitymustbeintheorderof O(log n).Ifthetargetisnotfoundinthearray,return [-1,-1].ExampleGiven
LiBlog
·
2015-01-09 08:00
LintCode
-Serialization and Deserialization Of Binary Tree
Designanalgorithmandwritecodetoserializeanddeserializeabinarytree.Writingthetreetoafileiscalled'serialization'andreadingbackfromthefiletoreconstructtheexactsamebinarytreeis'deserialization'.Thereisnol
LiBlog
·
2015-01-08 12:00
封装异步线程回调接口更新UI图片
代码如下:封装工具类publicclassDownLoadContent{ privateProgressDialogdialog; privatestaticfina
lintcode
=1;
KT.G
·
2014-12-29 10:00
封装异步线程回调接口更新UI图片
代码如下:封装工具类publicclassDownLoadContent{privateProgressDialogdialog;privatestaticfina
lintcode
=1;publicDownLoadContent
KT.G
·
2014-12-29 10:00
LintCode
-Longest Increasing Subsequence
Givenasequenceofintegers,findthelongestincreasingsubsequence(LIS).YoucodeshouldreturnthelengthoftheLIS.ExampleFor[5,4,1,2,3],theLIS is[1,2,3],return3For[4,2,4,5,3,7],theLISis[4,4,5,7],return4Challenge
LiBlog
·
2014-12-29 04:00
【
lintcode
】树形数据结构之Maxtree, Tree iterator, remove bst node, 优先队列之动态中位数Median, 矩阵dfs之word search II,最大连
substrdiff: 无queue的区间滑动窗口,记录当前最大值maxtree:http://
lintcode
.com/submission/60239/九章算法中有讲到,对每个节点,找到离他最近且比它大的左右两个节点中较小的那个
brandohero
·
2014-12-11 01:00
#
LintCode
# Binary Search
既然是菜鸟,就从基础题开始做起吧,争取做一题有一题的收获.---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ChiBaoNeLiuLiuNi
·
2014-09-17 14:00
binarySearch
lintcode
上一页
79
80
81
82
83
84
85
86
下一页
按字母分类:
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
其他