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
59 3Sum Closest solution 题解
【题目描述】GivenanarraySofnintegers,findthreeintegersinSsuchthatthesumisclosesttoagivennumber,target.Returnthesumofthethreeintegers.Notice:Youmayassumethateachinputwouldhaveexactlyonesolution.给一个包含n个整数的数组S
代码码着玩
·
2019-12-01 07:56
OJ
lintcode
等价二叉树
检查两棵二叉树是否等价。等价的意思是说,首先两棵二叉树必须拥有相同的结构,并且每个对应位置上的节点上的数都相等。image.png/***DefinitionofTreeNode:*classTreeNode{*public:*intval;*TreeNode*left,*right;*TreeNode(intval){*this->val=val;*this->left=this->right=
zhaozhengcoder
·
2019-12-01 07:05
lintcode
unique Binary Search Tree 不同的二叉查找树
Givenn,howmanystructurallyuniqueBST's(binarysearchtrees)thatstorevalues1...n?Forexample,Givenn=3,thereareatotalof5uniqueBST's.13321\///\\321132//\\2123给出n,问由1...n为节点组成的不同的二叉查找树有多少种?思路:可以用分治的方法解决,二叉查找树
111浪子111
·
2019-12-01 05:54
lintCode
题解(3)
标签(空格分隔):
lintCode
题目:统计数字描述:计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例例如n=12,k=1,在[0,1,2,3,4,5,6,7,8,9,10,11,12],我们发现
Sivin
·
2019-12-01 03:57
kth smallest element in an array
Questionfrom
lintcode
Givenanunsortedarray,findthekthsmallestelement.IdeaUseanysortalgorithmyouarefamiliarwith.Iimplementedaheapwithanarray.ThisarrayimplementationisbroughtfromMarkAllenWeiss'sDataStruct
Star_C
·
2019-12-01 03:25
Lintcode
528 Flatten Nested List Iterator solution 题解
【题目描述】Givenanestedlistofintegers,implementaniteratortoflattenit.Eachelementiseitheraninteger,oralist--whoseelementsmayalsobeintegersorotherlists.NoticeYoudon'tneedtoimplementtheremovemethod.给你一个嵌套的列表,
程风破浪会有时
·
2019-12-01 03:24
Lintcode
64 Merge Sorted Array solution 题解
【题目描述】GiventwosortedintegerarraysAandB,mergeBintoAasonesortedarray.Notice:YoumayassumethatAhasenoughspace(sizethatisgreaterorequaltom+n)toholdadditionalelementsfromB.ThenumberofelementsinitializedinAa
代码码着玩
·
2019-12-01 02:11
LintCode
249 [Count the Smaller Number before itself]
原题给定一个整数数组(下标由0到n-1,n表示数组的规模,取值范围由0到10000)。对于数组中的每个ai元素,请计算ai前的数中比它小的元素的数量。对于数组[1,2,7,8,5],返回[0,1,2,3,2]解题思路建立值型线段树首先建立树count都等于0,然后循环query再modify注意查找x-1可能出现负值,要做判断,x-10:ans=self.query(root,0,num-1)se
Jason_Yuan
·
2019-12-01 01:59
Lintcode
65 Median of two Sorted Arrays solution 题解
【题目链接】www.
lintcode
.com/en/problem/median-of-two-sorted
代码码着玩
·
2019-11-30 18:33
整理了一下自己找资料时经常会使用到的网站或者论坛
stackoverflow.comstackoverflow开源社区http://github.comGitHub开源中心http://codecanyon.net代码也可以放在网上卖的的网站https://www.
lintcode
.com
Youmi丶
·
2019-11-30 16:00
Folding Array
http://www.
lintcode
.com/zh-cn/problem/folding-array/importjava.util.ArrayList;importjava.util.Collections
天街孤独
·
2019-11-30 16:51
Lintcode
45 Maximum Subarray Difference solution 题解
【题目描述】Givenanarraywithintegers.Findtwonon-overlappingsubarraysAandB,which|SUM(A)-SUM(B)|isthelargest.Returnthelargestdifference.Notice:Thesubarrayshouldcontainatleastonenumber给定一个整数数组,找出两个不重叠的子数组A和B,使
代码码着玩
·
2019-11-30 15:36
LintCode
- 克隆二叉树(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:深度复制一个二叉树。给定一个二叉树,返回一个他的克隆品。样例给定一个二叉树:1/\23/\45返回其相同结构相同数值的克隆二叉树:1/\23/\45思路:递归/***DefinitionofTreeNode:*publicclassTreeNode{*publicintval;*publicTreeNodeleft,right;*
柒黍
·
2019-11-30 14:18
Search Range in Binary Search Tree
SearchRangeinBinarySearchTree今天是一道有关二叉树的题目,来自
LintCode
,难度为Medium。
ab409
·
2019-11-30 04:41
OJ
lintcode
克隆二叉树
深度复制一个二叉树。给定一个二叉树,返回一个他的克隆品。您在真实的面试中是否遇到过这个题?Yes样例给定一个二叉树:1/23/45返回其相同结构相同数值的克隆二叉树:1/23/45classSolution{public:/***@paramroot:Therootofbinarytree*@returnrootofnewtree*/TreeNode*cloneTree(TreeNode*root
zhaozhengcoder
·
2019-11-30 01:22
OJ:
lintcode
平衡二叉树
给定一个二叉树,确定它是高度平衡的。对于这个问题,一棵高度平衡的二叉树的定义是:一棵二叉树中每个节点的两个子树的深度相差不会超过1。您在真实的面试中是否遇到过这个题?image.png/***DefinitionofTreeNode:*classTreeNode{*public:*intval;*TreeNode*left,*right;*TreeNode(intval){*this->val=v
zhaozhengcoder
·
2019-11-29 23:56
整理一些不错的编程学习网站
stackoverflow.comstackoverflow开源社区http://github.comGitHub开源中心http://codecanyon.net代码也可以放在网上卖的的网站https://www.
lintcode
.com
折蕊君
·
2019-11-29 12:00
到达一个数字
https://www.
lintcode
.com/problem/reach-a-number/descriptionpublicclassSolution{/***@paramtarget:thedestination
天街孤独
·
2019-11-29 11:50
Lintcode
61 Search for a Range solution 题解
【题目描述】Givenasortedarrayofnintegers,findthestartingandendingpositionofagiventargetvalue.Ifthetargetisnotfoundinthearray,return[-1,-1].给定一个包含n个整数的排序数组,找出给定目标值target的起始和结束位置。如果目标值不在数组中,则返回[-1,-1]【题目链接】ww
代码码着玩
·
2019-11-29 05:46
Lintcode
60 Search Insert Position 题解
【题目描述】Givenasortedarrayandatargetvalue,returntheindexifthetargetisfound.Ifnot,returntheindexwhereitwouldbeifitwereinsertedinorder.YoumayassumeNOduplicatesinthearray.给定一个排序数组和一个目标值,如果在数组中找到目标值则返回索引。如果没
代码码着玩
·
2019-11-28 04:46
Lintcode
150 Best Time to Buy and Sell Stock II solution 题解
【题目描述】Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteasmanytransactionsasyoulike(ie,buyoneandselloneshareofthestockmultipleti
程风破浪会有时
·
2019-11-28 03:58
LintCode
- 合并排序数组(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:合并两个排序的整数数组A和B变成一个新的数组。样例给出A=[1,2,3,4],B=[2,4,5,6],返回**[1,2,2,3,4,4,5,6]**思路:归并排序/***@paramAandB:sortedintegerarrayAandB.*@return:Anewsortedintegerarray*/publicint[]m
柒黍
·
2019-11-28 01:03
Lintcode
189 First Missing Positive solution 题解
【题目链接】www.
lintcode
.com/en/problem/first-missing-positive/【题目解析】此题可用桶排序。
程风破浪会有时
·
2019-11-28 01:13
LintCode
平衡二叉树
题目给定一个二叉树,确定它是高度平衡的。对于这个问题,一棵高度平衡的二叉树的定义是:一棵二叉树中每个节点的两个子树的深度相差不会超过1。样例给出二叉树A={3,9,20,#,#,15,7},B={3,#,20,15,7}balence.PNG二叉树A是高度平衡的二叉树,但是B不是分析首先求深度,然后判断深度相差是否超过1,注意递归的使用代码/***DefinitionofTreeNode:*pub
六尺帐篷
·
2019-11-28 00:17
LintCode
问题图解-58
本文准备讲解1个算法编程问题,这个算法编程问题来自
LintCode
平台。不了解.
LintCode
平台的读者可以阅读笔者文章(在线编程平台推荐-LeetCode)。
billliu_0d62
·
2019-11-27 22:02
Lintcode
221 Add Two Numbers II solution 题解
【题目描述】Youhavetwonumbersrepresentedbyalinkedlist,whereeachnodecontainsasingledigit.Thedigitsarestoredinforwardorder,suchthatthe1'sdigitisattheheadofthelist.Writeafunctionthataddsthetwonumbersandreturns
程风破浪会有时
·
2019-11-08 20:03
LeetCode and
LintCode
: Binary Tree
ValidateBinarySearchTreeMethod:TraverseandDivideandConquer.IfitisavalidBST,usein-ordertraverseandgetthealist.Thelistshouldbesorteduniqueincreasinglist.Divideandconquer:Everytime,remembertheminvalue,ma
TQINJS
·
2019-11-08 18:08
LintCode
完美平方
题目给一个正整数n,找到若干个完全平方数(比如1,4,9,...)使得他们的和等于n。你需要让平方数的个数最少。样例给出n=12,返回3因为12=4+4+4。给出n=13,返回2因为13=4+9。分析动态规划,dp[i]表示n=i时,最小的个数。显然可以求出dp值为1的值,并以此进行判断代码publicclassSolution{/***@paramnapositiveinteger*@retur
六尺帐篷
·
2019-11-08 16:31
LintCode
_chapter2_section11_remove-duplicates-from-sorted-array-ii
coding=utf-8'''Createdon2015年11月10日@author:SphinxW'''#删除排序数组中的重复数字II##跟进“删除重复数字”:##如果可以允许出现两次重复将如何处理?###样例##给出数组A=[1,1,1,2,2,3],你的函数应该返回长度5,此时A=[1,1,2,2,3]。classSolution:"""@paramA:alistofintegers@ret
穆弋
·
2019-11-08 16:29
LintCode
最长上升连续子序列
题目给定一个整数数组(下标从0到n-1,n表示整个数组的规模),请找出该数组中的最长上升连续子序列。(最长上升连续子序列可以定义为从右到左或从左到右的序列。)样例给定[5,4,2,1,3],其最长上升连续子序列(LICS)为[5,4,2,1],返回4.给定[5,1,2,3,4],其最长上升连续子序列(LICS)为[1,2,3,4],返回4.分析1(普通解法)最简单的思路,遍历两遍,正向和反向各一遍
六尺帐篷
·
2019-11-08 14:04
Twitter SDE 电面面经
因为在
lintcode
上做过大量类似题目,所以只花了半个小时就完成了这套测试。两天后,接到了twitter的电面电话。面试官主要对简历上的项目进行了简单了解然后进行了算法考察。
程风破浪会有时
·
2019-11-08 06:13
OJ
lintcode
移动零
给一个数组nums写一个函数将0移动到数组的最后面,非零元素保持原数组的顺序注意事项1.必须在原数组上操作2.最小化操作数您在真实的面试中是否遇到过这个题?Yes样例给出nums=[0,1,0,3,12],调用函数之后,nums=[1,3,12,0,0]./*这个也可以通过oj不过时间复杂度比较高classSolution{public:/***@paramnumsanintegerarray*@
zhaozhengcoder
·
2019-11-08 04:06
Binary Tree Maximum Path Sum (
Lintcode
94)
这道题算是Divide&Conquer中比较难的了。下面给出topdown和bottomup两种做法。TopDown的做法是,对于每一点root,求出包含root->left的最大pathsum,和包含root->right的最大pathsum,将root->left,与root->right的最大pathsum分别与0比较,然后与root->val相加,就是root这一点的最大和。我们记录一个m
stepsma
·
2019-11-08 01:53
LintCode
_chapter1_section5_longest-common-substring
coding=utf-8'''Createdon2015年11月6日@author:SphinxW'''#长公共子串##给出两个字符串,找到最长公共子串,并返回其长度。###您在真实的面试中是否遇到过这个题?#样例##给出A=“ABCD”,B=“CBCE”,返回2#注意##子串的字符应该连续的出现在原字符串中,这与子序列有所不同。classSolution:#@paramA,B:Twostring
穆弋
·
2019-11-08 01:32
Data Stream Median Summary (Leetcode 295,
Lintcode
81,
Lintcode
360)
这类题是一类典型的twopriorityqueue的题目。维护两个heap,一个MinHeap,一个MaxHeap。本解法中,MaxHeap的在奇数时会多一个,奇数时返回MaxHeap的top(注意这里面的逻辑,如果先往MaxHeap放,那么MaxHeap就一定要多一个)。另外注意,c++此题直接用multiset来实现priority_queue。如果priority_queue里面装的是int
stepsma
·
2019-11-08 00:34
[
LintCode
][Two Pointers] Two Sum II.md
ProblemMoreDiscussionsGivenanarrayofintegers,findhowmanypairsinthearraysuchthattheirsumisbiggerthanaspecifictargetnumber.Pleasereturnthenumberofpairs.ExampleGivennumbers=[2,7,11,15],target=24.Return1.
楷书
·
2019-11-07 22:48
LintCode
接雨水
题目给出n个非负整数,代表一张X轴上每个区域宽度为1的海拔图,计算这个海拔图最多能接住多少(面积)雨水。Paste_Image.png样例如上图所示,海拔分别为[0,1,0,2,1,0,1,3,2,1,2,1],返回6.分析有三种方法思路可以解决方法一:首先从左遍历一遍,找到已左边为基准的高度再从右边遍历一遍找到以右边为基准的高度,要能够接住水,就要求左右两边,最小的一边的高度应该比中间的都要大,
六尺帐篷
·
2019-11-07 20:01
OJ
lintcode
二分查找
给定一个排序的整数数组(升序)和一个要查找的整数target,用O(logn)的时间查找到target第一次出现的下标(从0开始),如果target不存在于数组中,返回-1。您在真实的面试中是否遇到过这个题?Yes样例在数组[1,2,3,3,4,5,10]中二分查找3,返回2。classSolution{public:/***这个题不难,很常见,但是有点卡顿*问题:*1.vector是可以按照下标
zhaozhengcoder
·
2019-11-07 19:51
[
LintCode
][System Design] Tiny Url II
ProblemAsafollowupforTinyURL,wearegoingtosupportcustomtinyurl,sothatusercancreatetheirowntinyurl.SolutionclassTinyUrl2{private:constlonglonghashSize=62^6;mapid2long;maplong2id;conststringtinyHeader="h
楷书
·
2019-11-07 18:44
Lintcode
153 Combination Sum II solution 题解
【题目描述】Givenacollectionofcandidatenumbers(C)andatargetnumber(T),findalluniquecombinationsinCwherethecandidatenumberssumstoT.EachnumberinCmayonlybeusedonceinthecombination.NoticeAllnumbers(includingtarg
程风破浪会有时
·
2019-11-07 18:32
LintCode
- 查找斐波纳契数列中第 N 个数(入门)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:查找斐波纳契数列中第N个数。所谓的斐波纳契数列是指:前2个数是0和1。第i个数是第i-1个数和第i-2个数的和。斐波纳契数列的前10个数字是:0,1,1,2,3,5,8,13,21,34...思路:题目较简单,需要注意的是输入参数N是1~N,比较常用思路是递归方法一:无脑循环法classSolution{/***@paramn:a
柒黍
·
2019-11-07 17:12
Lintcode
98 Sort List solution 题解
【题目链接】www.
lintcode
.com/en/problem/sort-list/【题目解析】此题可以归并排序。以下归并排序实现的几个要素。
程风破浪会有时
·
2019-11-07 16:59
Lintcode
143 Sort Colors || solution 题解
【题目描述】Givenanarrayofnobjectswithkdifferentcolors(numberedfrom1tok),sortthemsothatobjectsofthesamecolorareadjacent,withthecolorsintheorder1,2,...k.NoticeYouarenotsupposetousethelibrary'ssortfunctionfor
程风破浪会有时
·
2019-11-07 15:53
LintCode
-407.加一
题目描述给定一个非负数,表示一个数字数组,在该数的基础上+1,返回一个新的数组。该数字按照大小进行排列,最大的数在列表的最前面。样例给定[1,2,3]表示123,返回[1,2,4].给定[9,9,9]表示999,返回[1,0,0,0].解答思路由于是加一,就简单多了。从后往前只要是某一位加1之后小于10。直接返回。加到最后一位都没有返回,说明要进1,而new出来的int[]默认设置为0,只需要把首
悠扬前奏
·
2019-11-07 11:28
LintCode
- 快乐数(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:写一个算法来判断一个数是不是"快乐数"。a一个数是不是快乐是这么定义的:对于一个正整数,每一次将该数替换为他每个位置上的数字的平方和,然后重复这个过程直到这个数变为1,或是无限循环但始终变不到1。如果可以变为1,那么这个数就是快乐数。样例19就是一个快乐数。1^2+9^2=828^2+2^2=686^2+8^2=1001^2+0^
柒黍
·
2019-11-07 11:32
lintcode
最大子数组
给定一个整数数组,找到一个具有最大和的子数组,返回其最大和。样例给出数组[−2,2,−3,4,−1,2,1,−5,3],符合要求的子数组为[4,−1,2,1],其最大和为6。从左到右依次相加,如果为负数舍去,为正数接着相加。设sum为和,那么当sum小于0时直接舍去前面所有的数,并将sum重置为0;classSolution{public:/***@paramnums:Alistofinteger
yzawyx0220
·
2019-11-07 10:00
LintCode
最长公共子串
给出两个字符串,找到最长公共子串,并返回其长度。注意事项子串的字符应该连续的出现在原字符串中,这与子序列有所不同。样例给出A=“ABCD”,B=“CBCE”,返回2代码publicclassSolution{/***@paramA,B:Twostring.*@return:thelengthofthelongestcommonsubstring.*/publicintlongestCommonSu
六尺帐篷
·
2019-11-07 10:50
lintcode
合并排序数组||
样例给出A=[1,2,3,empty,empty],B=[4,5]合并之后A将变成[1,2,3,4,5]题目链接:http://www.
lintcode
.com/zh-cn/problem/merge-sorted-array
yzawyx0220
·
2019-11-07 09:15
Lintcode
135 Combination Sum solution 题解
【题目描述】Givenasetofcandidatenumbers(C)andatargetnumber(T),findalluniquecombinationsinCwherethecandidatenumberssumstoT.ThesamerepeatednumbermaybechosenfromCunlimitednumberoftimes.Notice·Allnumbers(includ
程风破浪会有时
·
2019-11-07 08:56
Lintcode
Naive题
366Fibonacci题目最初、最容易想到的解法是利用递归,即(fibonacci(n-1)+fibonacci(n-2)),这种解法会在提交的时候报时间复杂度过高。因此只能用按照题目中的书面意思翻译成代码的方式写出答案。publicintfibonacci(intn){inta=0;intb=1;inttemp;for(inti=1;i
吕逸涛任春晚
·
2019-11-07 07:48
上一页
52
53
54
55
56
57
58
59
下一页
按字母分类:
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
其他