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
1206. 下一个更大的数 I
你有两个数组nums1和nums2(互不重复),其中nums1是nums2的子集。在nums2的相应位置找到nums1所有元素的下一个更大数字。nums1中的数字x的下一个更大数字是nums2中x右边第一个更大的数字。如果它不存在,则为此数字输出-1。例子1:输入:nums1=[4,1,2],nums2=[1,3,4,2].输出:[-1,3,-1]解释:对于第一个数组中的数字4,在第二个数组中找不
Sinb妃
·
2020-08-26 15:10
[
LintCode
/LeetCode] Min Stack/Max Stack
ProblemImplementastackwithmin()function,whichwillreturnthesmallestnumberinthestack.Itshouldsupportpush,popandminoperationallinO(1)cost.Examplepush(1)pop()//return1push(2)push(3)min()//return2push(1)mi
weixin_34249678
·
2020-08-26 15:15
LintCode
-下一个排列
给定一个若干整数的排列,给出按正数大小进行字典序从小到大排序后的下一个排列。如果没有下一个排列,则输出字典序最小的序列。样例左边是原始排列,右边是对应的下一个排列。1,2,3→1,3,23,2,1→1,2,31,1,5→1,5,1挑战不允许使用额外的空间。分析:从后往前找,找到第一对(i,j),使得nums[i]&nums){//writeyourcodehereintn=nums.size();
wangyuquan
·
2020-08-26 14:20
面试
leetcode——双序列DP系列
文章目录最长公共子序列交错字符串编辑距离最长公共子序列leetcode好像没有这个题,取
lintcode
找了一个,结果不能用C#。。。于是写出了时隔N年的第一段Java代码。。
Sophie1797
·
2020-08-26 13:11
基础算法
LintCode
-分治-合并k个排序链表
点此进入题目解题思路:这道题目是将vector函数中所有链表给组合在一起然后输出,而且存在vector函数的单链表是已经排序了的。这道题可以用分治递归的方法做,首先将vector函数的所有单链表两两组合在一起,然后添加在vector函数后面,若最后有一个单链表剩余那么直接跳过。然后将vector进行递归,直到单链表数量为1.解题过程:给定一个vecto&lists数组,判断lists长度是否为0,
lz1997
·
2020-08-26 13:02
lintcode
LINTCODE
:496 下一个最大元素I(Python语言实现)
题目描述给定两个没有重复元素的数组nums1和nums2,其中nums1是nums2的子集。找到nums1中每个元素在nums2中的下一个比其大的值。nums1中数字x的下一个更大元素是指x在nums2中对应位置的右边的第一个比x大的元素。如果不存在,对应位置输出-1。示例1输入nums1=[4,1,2],nums2=[1,3,4,2]输出[-1,3,-1]解释对于nums1中的数字4,你无法在第
王山山
·
2020-08-26 11:41
PROGRAM
简单动态规划总结
[最长递增子序列(LIS)]4.LongestConsecutiveSequence5.
lintcode
:MaximumSubarray6.
lintcode
:MaximumProductSubarray
知之可否
·
2020-08-25 11:07
面经
【
LintCode
-408】二进制求和(Java实现)
第一次代码记录(不带注释版本):publicStringaddBinary(Stringa,Stringb){intalength=a.length();intblength=b.length();Stringresult="";intsum=0;while(alength>=1||blength>=1){if(alength>=1){sum+=Integer.parseInt(a.substri
D.Chuan
·
2020-08-25 11:16
数据结构
微软SDE面经(电面+onsite)
LintCode
原题:http://www.
lintcode
.com/
weixin_34205076
·
2020-08-25 08:41
Lintcode
463 Sort Integers solution 题解
【题目链接】www.
lintcode
.com/en/problem/sort-integer
程风破浪会有时
·
2020-08-25 07:33
【
LintCode
题解】微软面试算法题:转换字符串到整数
题目描述实现atoi这个函数,将一个字符串转换为整数。如果没有合法的整数,返回0。如果整数超出了32位整数的范围,返回INT_MAX(2147483647)如果是正整数,或者INT_MIN(-2147483648)如果是负整数。样例1输入:"10"输出:10样例2输入:"1"输出:1样例3输入:"123123123123123"输出:2147483647说明:因为123123123123123>I
九章算法
·
2020-08-25 06:00
九章算法面试题
lintcode
,最多有多少个点在一条直线上
给出二维平面上的n个点,求最多有多少点在同一条直线上。样例给出4个点:(1,2),(3,6),(0,0),(1,3)。一条直线上的点最多有3个。解题思路:从第一个点开始遍历,每次和其他所有点对比,判断是否是重合点,以及是否是同一x值的点,map用来保存斜率,然后判断斜率是否存在,每次更新max。一刷没ac/***Definitionforapoint.*classPoint{*intx;*inty
zsjmfy
·
2020-08-25 06:31
lintcode
最多有多少个点在一条直线上-
LintCode
给出二维平面上的n个点,求最多有多少点在同一条直线上。样例:给出4个点:(1,2),(3,6),(0,0),(1,3)。一条直线上的点最多有3个。思想:利用map#ifndefC186_H#defineC186_H#include#include#include#includeusingnamespacestd;structPoint{intx;inty;Point():x(0),y(0){}Po
zhaokane
·
2020-08-25 06:42
LintCode
最长上升子序列-
LintCode
给定一个整数序列,找到最长上升子序列(LIS),返回LIS的长度。说明:最长上升子序列的定义:最长上升子序列问题是在一个无序的给定序列中找到一个尽可能长的由低到高排列的子序列,这种子序列不一定是连续的或者唯一的。样例:给出[5,4,1,2,3],LIS是[1,2,3],返回3给出[4,2,4,5,3,7],LIS是[2,4,5,7],返回4思路:动态规划,构建数组res[],res[i]表示已以元
zhaokane
·
2020-08-25 06:41
LintCode
C++
【两次过】
Lintcode
235. 分解质因数
将一个整数分解为若干质因数之乘积样例给出10,返回[2,5].给出660,返回[2,2,3,5,11].注意事项你需要从小到大排列质因子。解题思路:i从2开始算起当i^2超过n时就不需要再考虑后面的数只要n%i==0可以整除就一直while循环直至终止该过程中不断缩小n并将结果加入到res中最后不要忘记最终得到的结果(ifnum>1)也加入进去publicclassSolution{/***@pa
小马哥MAX
·
2020-08-25 03:14
lintcode
[
LintCode
383] 装最多水的容器(Python)
题目描述给定n个非负整数a1,a2,…,an,每个数代表了坐标中的一个点(i,ai)。画n条垂直线,使得i垂直线的两个端点分别为(i,ai)和(i,0)。找到两条线,使得其与x轴共同构成一个容器,以容纳最多水。注意事项容器不可倾斜。样例给出[1,3,2],最大的储水面积是2.思路两侧不断向一起逼近。每次计算面积为横坐标之差乘以纵坐标较小的数值,并更新最大值。若纵坐标较小的数值在左边,则向右移一位;
愚人国王
·
2020-08-25 01:18
算法
【
LintCode
】Pattern(C语言实现)
题目描述Givenasequenceofnintegersa1,a2,…,an,a132patternisasubsequenceai,aj,aksuchthati#definetrue1#definefalse0#defineVSIZE100#defineSSIZE100#defineINT_MIN-10000000typedefunsignedcharbool;typedefstruct{in
colorfulshark
·
2020-08-25 01:57
面试题
LintCode
-装最多水的容器
给定n个非负整数a1,a2,...,an,每个数代表了坐标中的一个点(i,ai)。画n条垂直线,使得i垂直线的两个端点分别为(i,ai)和(i,0)。找到两条线,使得其与x轴共同构成一个容器,以容纳最多水。样例给出[1,3,2],最大的储水面积是2.注意容器不可倾斜。分析:采用两边逼近法,显而易见,当逐渐逼近的时候,容器的长在变短,那么要使得面积增大的话,宽必须要变大,所以我们保留长的那条线段,使
wangyuquan
·
2020-08-25 01:24
面试
Lintcode
C++代码
查超字符串对于一个给定的source字符串和一个target字符串,你应该在source字符串中找出target字符串出现的第一个位置(从0开始)。如果不存在,则返回-1。classSolution{public:/***Returnsaindextothefirstoccurrenceoftargetinsource,*or-1iftargetisnotpartofsource.*@params
年轻的老干爹
·
2020-08-25 01:40
LintCode
1.A+B问题 C语言
问题描述:给出两个整数a和b,求他们的和,但不能使用+等数学运算符。样例:如果a=1并且b=2,返回3分析:不能使用数学运算符,我们就要转而考虑位运算符了,a和b的异或运算被称作没有进位的加法运算。可以想一下,异或运算,1和1相加,结果为0进位为1,0和0相加还是0,1和0还有0和1相加都是1,后三种情况都没有进位(或进位为0)。那么,只有1和1的情况下产生了进位,这种正好符合与运算只有两者都为1
Glorious只為你
·
2020-08-25 01:36
C语言
LintCode
lintcode
刷题——装最多水的容器
lintcode
刷题之装最多水的容器,原题如下所示:给定n个非负整数a1,a2,...,an,每个数代表了坐标中的一个点(i,ai)。
yige321
·
2020-08-25 00:27
lintcode刷题
【
LintCode
】判断一个字符串是否包含另一个字符串的所有字符
问题描述:比较两个字符串A和B,确定A中是否包含B中所有的字符。字符串A和B中的字符都是大写字母。样例给出A=“ABCD”B=“ACD”,返回true给出A=“ABCD”B=“AABC”,返回false注意事项在A中出现的B字符串里的字符不需要连续或者有序。问题分析:比喻一个场景,甲和乙手里有纸牌A到Z,判断甲包含乙手里的牌首先把甲的牌哈希一下吧,A到Z分别有多少张然后A到Z张数循环减去乙手里的牌
Panamera985
·
2020-08-25 00:24
算法
[
LintCode
]判断一个字符串是否包含另一个字符串的所有字符
问题描述:比较两个字符串A和B,确定A中是否包含B中所有的字符。字符串A和B中的字符都是大写字母。样例给出A="ABCD"B="ACD",返回true给出A="ABCD"B="AABC",返回false注意事项在A中出现的B字符串里的字符不需要连续或者有序。问题分析:实质上利用的是哈希表的思想。只有大写字母,一共26个,遍历A的时候,往里面压,遍历B的时候,往外边弹,如果不够弹,则不包含。问题解决
H_MZ
·
2020-08-24 23:56
matlab
woodcut
http://www.
lintcode
.com/en/problem/wood-cut/#二分答案,贪心验证,具有单调性classSolution{public:/***@paramL:GivennpiecesofwoodwithlengthL
richardzrc
·
2020-08-24 23:21
数据结构
面试算法
Algorithm ladder II
Dec25,26.Mission:
lintcode
459ClosestNumberinSortedArray
lintcode
458last-position-of-target
lintcode
28Searcha2DMatrix
lintcode
585MaximumNumberinMountainSequence
lintcode
447SearchinaBigSortedArray
lintcode
159
aureole420
·
2020-08-24 22:39
[算法]——集合子集
LintCode
一种通常的做法是:对于集合中的任意一个元素e,有两种可能:被选中作为子集中的元素,或否。因此,一个包含N个元素的集合,共有2^N个子集。
weixin_30897079
·
2020-08-24 17:32
[
LintCode
] 604. Design Compressed String Iterator
ProblemDesignandimplementadatastructureforacompressedstringiterator.Itshouldsupportthefollowingoperations:nextandhasNext.Thegivencompressedstringwillbeintheformofeachletterfollowedbyapositiveintegerre
linspiration
·
2020-08-24 14:16
java
iterator
[
LintCode
/LeetCode] Meeting Rooms
ProblemGivenanarrayofmeetingtimeintervalsconsistingofstartandendtimes[[s1,e1],[s2,e2],...](siintervals){//Writeyourcodehereintsize=intervals.size();for(inti=0;ib.start&&a.starta.start&&b.startlist=Arr
linspiration
·
2020-08-24 14:31
interval
java
sort
[
LintCode
/LeetCode] Remove Duplicate Letters
ProblemGivenastringwhichcontainsonlylowercaseletters,removeduplicateletterssothateveryletterappearonceandonlyonce.Youmustmakesureyourresultisthesmallestinlexicographicalorderamongallpossibleresults.Ex
linspiration
·
2020-08-24 14:33
LintCode
leetcode
java
stack
Spring 解决RestController返回枚举对象时输出的是枚举的名称而不是json字符串
SUCCESS(0,"成功登入"),USER_NOT_FOUND(1,"未找到用户"),INCORRECT_PASS(2,"密码错误"),INCORRECT_CODE(3,"验证码错误");privatefina
lintcode
A__Plus
·
2020-08-24 13:04
[
LintCode
/LeetCode] Median of two Sorted Arrays
ProblemTherearetwosortedarraysAandBofsizemandnrespectively.Findthemedianofthetwosortedarrays.ExampleGivenA=[1,2,3,4,5,6]andB=[2,3,4,5],themedianis3.5.GivenA=[1,2,3]andB=[4,5],themedianis3.ChallengeThe
linspiration
·
2020-08-24 13:57
java
binary-search
divide-conquer
[
LintCode
/LeetCode] Balanced Binary Tree
ProblemGivenabinarytree,determineifitisheight-balanced.Forthisproblem,aheight-balancedbinarytreeisdefinedasabinarytreeinwhichthedepthofthetwosubtreesofeverynodeneverdifferbymorethan1.ExampleGivenbinar
linspiration
·
2020-08-24 13:44
java
divide-conquer
recursion
[
LintCode
/LeetCode] Binary Tree Maximum Path Sum
ProblemGivenabinarytree,findthemaximumpathsum.Thepathmaystartandendatanynodeinthetree.ExampleGiventhebelowbinarytree:1/\23return6.Note调用helper函数更新路径和的最大值res,而helper函数本身需要递归,返回的是单边路径和single。这里需要注意:对于拱形
linspiration
·
2020-08-24 13:44
java
recursion
divide-conquer
[
LintCode
] Sort List [分治]
ProblemSortalinkedlistinO(nlogn)timeusingconstantspacecomplexity.ExampleGiven1-3->2->null,sortitto1->2->3->null.Note这道题目可以用分治法来做,首先从链表中点分割链表,然后将两个链表重新排序并合并。SolutionpublicclassSolution{publicListNodeso
linspiration
·
2020-08-24 13:43
java
linkedlist
recursion
divide-conquer
[
LintCode
/LeetCode] Validate Binary Search Tree
ProblemGivenabinarytree,determineifitisavalidbinarysearchtree(BST).AssumeaBSTisdefinedasfollows:Theleftsubtreeofanodecontainsonlynodeswithkeyslessthanthenode'skey.Therightsubtreeofanodecontainsonlynod
linspiration
·
2020-08-24 13:43
binary-tree
recursion
divide-conquer
dfs
[
LintCode
/LeetCode] Maximum Depth of Binary Tree
ProblemGivenabinarytree,finditsmaximumdepth.Themaximumdepthisthenumberofnodesalongthelongestpathfromtherootnodedowntothefarthestleafnode.ExampleGivenabinarytreeasfollow:1/\23/\45Themaximumdepthis3.Not
linspiration
·
2020-08-24 13:43
jav
binary-tree
divide-conquer
recursion
[
LintCode
/LeetCode] Implement Trie
,andstartsWithmethods.NoticeYoumayassumethatallinputsareconsistoflowercaselettersa-z.Exampleinsert("
lintcode
linspiration
·
2020-08-24 13:04
java
trie
前缀树
字典树
[
LintCode
/LeetCode] Maximum Product Subarray
ProblemFindthecontiguoussubarraywithinanarray(containingatleastonenumber)whichhasthelargestproduct.ExampleForexample,giventhearray[2,3,-2,4],thecontiguoussubarray[2,3]hasthelargestproduct=6.Note这是一道简单
linspiration
·
2020-08-24 13:24
java
linkedin
subarray
[
LintCode
] Interval Sum
ProblemGivenanintegerarray(indexfrom0ton-1,wherenisthesizeofthisarray),andanquerylist.Eachqueryhastwointegers[start,end].Foreachquery,calculatethesumnumberbetweenindexstartandendinthegivenarray,return
linspiration
·
2020-08-24 13:23
interval
java
binary-tree
segment-tree
[LeetCode/
LintCode
] Merge Intervals
ProblemGivenacollectionofintervals,mergealloverlappingintervals.ExampleGivenintervals=>mergedintervals:[[[1,3],[1,6],[2,6],=>[8,10],[8,10],[15,18][15,18]]]ChallengeO(nlogn)timeandO(1)extraspace.Note方法
linspiration
·
2020-08-24 13:10
java
interval
sort
数组
[
LintCode
] Implement Trie
ProblemImplementatriewithinsert,search,andstartsWithmethods.Exampleinsert("
lintcode
")search("code")//
linspiration
·
2020-08-24 13:08
java
trie
important
[
LintCode
] Simplify Path [字符串操作]
ProblemGivenanabsolutepathforafile(Unix-style),simplifyit.Example"/home/",=>"/home"//去掉末尾的slash"/a/./b/../../c/",=>"/c"//每个"/../"对应:删除一个上层的segmentChallengeDidyouconsiderthecasewherepath="/../"?Inthisc
linspiration
·
2020-08-24 13:07
java
string
stack
switch语句
[
LintCode
] Evaluate Reverse Polish Notation
ProblemEvaluatethevalueofanarithmeticexpressioninReversePolishNotation.Validoperatorsare+,-,*,/.Eachoperandmaybeanintegeroranotherexpression.Example["2","1","+","3","*"]->((2+1)*3)->9["4","13","5","/"
linspiration
·
2020-08-24 13:06
java
stack
switch语句
[
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
·
2020-08-24 13:05
java
hash
hashtable
mathematics
point
[
LintCode
] Number of Airplanes in the Sky
ProblemGivenanintervallistwhichareflyingandlandingtimeoftheflight.Howmanyairplanesareontheskyatmost?Note遍历List中的Interval,把start到end之间每一个数(左闭右开:起飞时刻在天上,降落时刻不在天上)存入HashMap。找到HashMap中的最大值。DefinitionofInt
linspiration
·
2020-08-24 13:31
hashmap
arraylist
interval
LintCode
Paint Fence
Thereisafencewithnposts,eachpostcanbepaintedwithoneofthekcolors.Youhavetopaintallthepostssuchthatnomorethantwoadjacentfencepostshavethesamecolor.Returnthetotalnumberofwaysyoucanpaintthefence.样例:Givenn
Arnold134777
·
2020-08-24 12:39
Lintcode
35.翻转链表
1.问题描述:翻转一个链表,将给定的链表按他相反的顺序表示。2.解题思路:相当于尾插法,创建dummy先保存了head的地址,将创建的temp保存head->next的地址,这样就让head下移,然后指回原来的地址,即使原来的链表断了,但还可以找到他的地址,就可以实现链表的翻转3.通过的代码:/***DefinitionofListNode**classListNode{*public:(*int
wyyyyyyyybiu
·
2020-08-24 10:31
链表
快乐数 (
lintcode
:happy-number)
写一个算法来判断一个数是不是"快乐数"。一个数是不是快乐是这么定义的:对于一个正整数,每一次将该数替换为他每个位置上的数字的平方和,然后重复这个过程直到这个数变为1,或是无限循环但始终变不到1。如果可以变为1,那么这个数就是快乐数。样例:19就是一个快乐数:19->82->68->100->1思路:对于非快乐数,如61,会有如下的循环过程:61->37->58->89->145->42->20->
v1coder
·
2020-08-24 09:11
LintCode
【简单】60. 搜索插入位置 。代码及思路
题目要求:给定一个排序数组和一个目标值,如果在数组中找到目标值则返回索引。如果没有,返回到它将会被按顺序插入的位置。你可以假设在数组中无重复元素。样例[1,3,5,6],5→2[1,3,5,6],2→1[1,3,5,6],7→4[1,3,5,6],0→0挑战O(log(n))time思路:因为给的是排序数组,所以很简单了,但是插入的时候要注意如果存在相等的数字,要插入到那个数字的前面。写完后发现挑
LimonSea
·
2020-08-24 07:03
LintCode
python_
lintcode
_167链表求和
167链表求和题目你有两个用链表代表的整数,其中每个节点包含一个数字。数字存储按照在原来整数中相反的顺序,使得第一个数字位于链表的开头。写出一个函数将两个整数相加,用链表形式返回和。样例给出两个链表3->1->5->null和5->9->2->null,返回8->0->8->null解析题目解析:一个整数,它被(0-9)按一个数字为一个节点,形成一个链表,所以每个节点都1->5->null5->9
xiongxu3381
·
2020-08-24 04:10
python_lintcode
上一页
14
15
16
17
18
19
20
21
下一页
按字母分类:
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
其他