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
题解 | 高盛面试真题:子数组的最大平均值
【题目描述】给定一个由n个整数组成的数组,找到给定长度k的连续子数组,该子数组具有最大平均值。你需要输出最大平均值。1<=k<=n<=30,000.给定数组的元素范围是[-10,000,10,000]。【题目样例】样例1输入:nums=[1,12,-5,-6,50,3]andk=4输出:12.75解释:最大平均为(12-5-6+50)/4=51/4=12.75样例2输入:nums=[4,2,1,3
SunnyZhao2019
·
2020-02-18 18:29
LintCode
1. A + B Problem
原题
LintCode
1.A+BProblemDescriptionWriteafunctionthataddtwonumbersAandB.Youshouldnotuse+oranyarithmeticoperators.ClarificationAreaandbboth32
Andiedie
·
2020-02-18 16:51
Longest Substring Without Repeating Characters(最长无重复字符的子串)
http://www.
lintcode
.com/zh-cn/problem/longest-substring-without-repeating-characters/?
天街孤独
·
2020-02-18 13:17
LintCode
Backpack VI
题目Givenanintegerarraynumswithallpositivenumbersandnoduplicates,findthenumberofpossiblecombinationsthatadduptoapositiveintegertarget.**注意事项**Thedifferentsequencesarecountedasdifferentcombinations.样例Giv
六尺帐篷
·
2020-02-18 11:56
LintCode
二叉树路径和 Binary Tree
classTreeNode:def__init__(self,val):self.val=valself.left,self.right=None,NoneclassSolution:"""二叉树的路径和{1,2,4,2,3}总和是5的所有路径"""allPath=[]defbinaryTreePathSum(self,root,target):ifrootisNone:returnNonesel
少年Amore
·
2020-02-18 06:33
Two Sum - BST edtion
http://www.
lintcode
.com/en/problem/two-sum-bst-edtion/?
天街孤独
·
2020-02-18 05:30
动态规划十大经典案例(Dynamic Programming Practice Problems)
MakingChange)LeetCode300最长上升子序列(LongestIncreasingSubsequence)堆盒子(BoxStacking)航线问题(BuildingBridges)01背包问题
lintcode
125
财神Childe
·
2020-02-17 22:20
数学
nlp
LintCode
129. 重哈希
原题解第一步,万年不变的查错。如果给的array是null或空,直接returnpublicListNode[]rehashing(ListNode[]hashTable){if(hashTable==null||hashTable.length==0){returnhashTable;}...}题目就是rehash,没什么复杂的算法,连hash的方式题目里都有了。就是先建一个比原来大一倍的新li
Jay_8d33
·
2020-02-17 18:14
Best Time to Buy and Sell Stock III(买卖股票的最佳时机 III)
http://www.
lintcode
.com/en/problem/best-time-to-buy-and-sell-stock-iii/publicclassSolution{/**@paramprices
天街孤独
·
2020-02-17 06:39
LintCode
丑数
题目写一个程序来检测一个整数是不是丑数。丑数的定义是,只包含质因子2,3,5的正整数。比如6,8就是丑数,但是14不是丑数以为他包含了质因子7。样例给出num=8,返回true。给出num=14,返回false。分析直接根据丑数的定义判断即可代码publicclassSolution{/***@paramnumaninteger*@returntrueifnumisanuglynumberorfa
六尺帐篷
·
2020-02-17 06:56
LintCode
-二叉树的前、中、后序遍历-递归
描述给出一棵二叉树,返回其节点值的前、中、后序遍历。样例给出一棵二叉树{1,#,2,3},12/3返回[3,2,1]挑战你能使用非递归实现么?代码(递归)前序遍历"""DefinitionofTreeNode:classTreeNode:def__init__(self,val):self.val=valself.left,self.right=None,None"""classSolution:
想当厨子的程序员
·
2020-02-17 06:33
Reverse Words in a String III
https://www.
lintcode
.com/problem/reverse-words-in-a-string-iii/descriptionpublicclassSolution{/***@params
天街孤独
·
2020-02-17 05:04
八 图与搜索-BFS
127.拓扑排序https://www.
lintcode
.com/zh-cn/problem/topological-sorting/#这道题分为三步。
西部小笼包
·
2020-02-17 04:26
[
lintcode
]95.验证二叉查找树
描述给定一个二叉树,判断它是否是合法的二叉查找树(BST)一棵BST定义为:节点的左子树中的值要严格小于该节点的值。节点的右子树中的值要严格大于该节点的值。左右子树也必须是二叉查找树。一个节点的树也是二叉查找树。代码/***DefinitionofTreeNode:*publicclassTreeNode{*publicintval;*publicTreeNodeleft,right;*publi
Titansonia
·
2020-02-17 03:50
LintCode
打劫房屋
假设你是一个专业的窃贼,准备沿着一条街打劫房屋。每个房子都存放着特定金额的钱。你面临的唯一约束条件是:相邻的房子装着相互联系的防盗系统,且当相邻的两个房子同一天被打劫时,该系统会自动报警。给定一个非负整数列表,表示每个房子中存放的钱,算一算,如果今晚去打劫,你最多可以得到多少钱在不触动报警装置的情况下。样例给定[3,8,4],返回8.挑战O(n)时间复杂度且O(1)存储。分析:定义dp[i]表示打
Arnold134777
·
2020-02-17 02:47
Maximal Square(最大正方形)
http://www.
lintcode
.com/en/problem/maximal-square/?
天街孤独
·
2020-02-17 01:25
Lintcode
132 Word Search || solution 题解
【题目描述】Givenamatrixofloweralphabetsandadictionary.Findallwordsinthedictionarythatcanbefoundinthematrix.Awordcanstartfromanypositioninthematrixandgoleft/right/up/downtotheadjacentposition.给出一个由小写字母组成的矩阵
程风破浪会有时
·
2020-02-16 18:48
Lintcode
415 Valid Palindrome solution 题解
【题目描述】Givenastring,determineifitisapalindrome,consideringonlyalphanumericcharactersandignoringcases.NoticeHaveyouconsiderthatthestringmightbeempty?Thisisagoodquestiontoaskduringaninterview.Forthepurpo
程风破浪会有时
·
2020-02-16 15:55
LintCode
: Flatten Binary Tree to Linked List
Flattenabinarytreetoafake"linkedlist"inpre-ordertraversal.HereweusetherightpointerinTreeNodeasthenextpointerinListNode.思路:定义一个空的stack用于存储暂时移出循环的右儿子们.然后在root或者stack不为空的时候,进行循环.在循环中,每当发现左儿子存在,则1.将右儿子压入s
阿斯特拉
·
2020-02-16 14:03
Java 算法-不同的二叉查找树I和II(动态规划和深搜算法)
二叉查找树在数据结构中学习,但是感觉自己学的非常水,最近在
lintCode
上做了两道的关于二叉查找树的题,感觉有比较记录下来,就当是增强记忆!
琼珶和予
·
2020-02-16 11:25
LintCode
49 [Sort Letters by Case]
原题给定一个只包含字母的字符串,按照先小写字母后大写字母的顺序进行排序。给出"abAcD",一个可能的答案为"acbAD"小写字母或者大写字母他们之间不一定要保持在原始字符串中的相对位置。在原地扫描一遍完成解题思路TwoPointers-对撞型指针问题做指针和右指针指向的字母,可能出现四种情况需要考虑:左:小写|右:小写====>左指针左移左:大写|右:小写====>交换字母左:大写|右:大写==
Jason_Yuan
·
2020-02-16 10:27
最常使用的k个单词(Map Reduce)
http://www.
lintcode
.com/zh-cn/problem/top-k-frequent-words-map-reduce/importjava.util.ArrayList;importjava.util.Collections
天街孤独
·
2020-02-16 08:51
LintCode
-编辑距离
给出两个单词word1和word2,计算出将word1转换为word2的最少操作次数。你总共三种操作方法:插入一个字符删除一个字符替换一个字符样例给出work1="mart"和work2="karma"返回3分析:minSteps[i][j]表示word1的前i个字符改为word2的前j个字符的最少操作数,因此有转移方程minSteps[i][j]={minSteps[i-1][j-1];(wor
Arnold134777
·
2020-02-16 02:43
Valid Word Abbreviation
https://www.
lintcode
.com/zh-cn/problem/valid-word-abbreviation/publicclassSolution{/***@paramword:anon-emptystring
天街孤独
·
2020-02-16 01:41
LintCode
二进制中有多少个1
题目计算在一个32位的整数的二进制表式中有多少个1.样例给定32(100000),返回1给定5(101),返回2给定1023(111111111),返回9分析方法一普通法最容易想到的方法,通过移位加计数,一个个计算统计1的个数publicintcountOnes1(intnum){intcount=0;while(num!=0){if(num%2==1)count++;num=num/2;}ret
六尺帐篷
·
2020-02-15 20:09
Lintcode
16 Permutations II solution 题解
【题目链接】http://www.
lintcode
.com/en/problem/permutations-ii/【题目解析】跟Permutations的解法一样,就是要考虑“去重”。先对数组进行排
代码码着玩
·
2020-02-15 10:14
LintCode
207 [Interval Sum II]
原题在类的构造函数中给一个整数数组,实现两个方法query(start,end)和modify(index,value):对于query(start,end),返回数组中下标start到end的和。对于modify(index,value),修改数组中下标为index上的数为value.给定数组A=[1,2,7,8,5].query(0,2),返回10.modify(0,4),将A[0]修改为4.
Jason_Yuan
·
2020-02-15 09:50
Minimum Size Subarray Sum(和大于S的最小子数组)
http://www.
lintcode
.com/zh-cn/problem/minimum-size-subarray-sum/?
天街孤独
·
2020-02-15 07:40
LintCode
- 合并两个排序链表(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:将两个排序链表合并为一个新的排序链表样例给出1->3->8->11->15->null,2->null,返回1->2->3->8->11->15->null。思路:/***@paramListNodel1istheheadofthelinkedlist*@paramListNodel2istheheadofthelinkedlis
柒黍
·
2020-02-15 05:00
LintCode
201 [Segment Tree Build]
原题线段树是一棵二叉树,他的每个节点包含了两个额外的属性start和end用于表示该节点所代表的区间。start和end都是整数,并按照如下的方式赋值:根节点的start和end由build方法所给出。对于节点A的左儿子,有start=A.left,end=(A.left+A.right)/2。对于节点A的右儿子,有start=(A.left+A.right)/2+1,end=A.right。如果
Jason_Yuan
·
2020-02-15 02:34
[
LintCode
][Trie] Add and Search Word
ProblemDesignadatastructurethatsupportsthefollowingtwooperations:addWord(word)andsearch(word)search(word)cansearchaliteralwordoraregularexpressionstringcontainingonlylettersa-zor..A.meansitcanrepresen
楷书
·
2020-02-15 01:27
LintCode
- 在O(1)时间复杂度删除链表节点(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:给定一个单链表中的一个等待被删除的节点(非表头或表尾)。请在在O(1)时间复杂度删除该链表节点。样例给定1->2->3->4,和节点3,删除3之后,链表应该变为1->2->4。/***DefinitionforListNode.*publicclassListNode{*intval;*ListNodenext;*ListNode
柒黍
·
2020-02-14 22:10
Segment Tree Build(线段树的构造)
http://www.
lintcode
.com/en/problem/segment-tree-build//***DefinitionofSegmentTreeNode:*publicclassSegmentTreeNode
天街孤独
·
2020-02-14 21:34
Find K Closest Elements
https://www.
lintcode
.com/zh-cn/problem/find-k-closest-elements/importjava.util.Arrays;publicclassSolution
天街孤独
·
2020-02-14 20:47
LintCode
564. Backpack VI
原题
LintCode
564.BackpackVIDescriptionGivenanintegerarraynumswithallpositivenumbersandnoduplicates,findthenumberofpossiblecombinationsthatadduptoapositiveintegertarget.NoticeAnumberinthearraycanbeusedmul
Andiedie
·
2020-02-14 18:40
LintCode
最小路径和
题目给定一个只含非负整数的m*n网格,找到一条从左上角到右下角的可以使数字和最小的路径。**注意事项你在同一时间只能向下或者向右移动一步**分析这是一道典型的动态规划的题目。我们从尾分析,达到右下角的只有两种可能,一种是通过向下走到右下角,一种是通过向右走到右下角。那么到达右下角的最小代价,就是这两种情况下的相对小的那个加上右下角这一步的代价。f(i,j)=MIN(f(i-1,j),f(i,j-1
六尺帐篷
·
2020-02-14 10:14
Interleaving Positive and Negative Numbers(交错正负数)
http://www.
lintcode
.com/zh-cn/problem/interleaving-positive-and-negative-numbers/publicclassSolution{
天街孤独
·
2020-02-14 09:50
OJ
lintcode
中位数
给定一个未排序的整数数组,找到其中位数。中位数是排序后数组的中间值,如果数组的个数是偶数个,则返回排序后数组的第N/2个数。您在真实的面试中是否遇到过这个题?Yes样例给出数组[4,5,1,2,3],返回3给出数组[7,9,4,5],返回5classSolution{public:/***@paramnums:Alistofintegers.*@return:Anintegerdenotesthe
zhaozhengcoder
·
2020-02-14 08:46
Lintcode
423 Valid Parentheses solution 题解
【题目链接】www.
lintcode
.com/en/problem/
程风破浪会有时
·
2020-02-14 03:03
lintcode
最小子串覆盖
给定一个字符串source和一个目标字符串target,在字符串source中找到包括所有目标字符串字母的子串。注意事项如果在source中没有这样的子串,返回"",如果有多个这样的子串,返回起始位置最小的子串。说明在答案的子串中的字母在目标字符串中是否需要具有相同的顺序?——不需要。样例给出source="ADOBECODEBANC",target="ABC"满足要求的解"BANC"这道题其实是
yzawyx0220
·
2020-02-14 01:33
Permutations II(带重复元素的排列)
http://www.
lintcode
.com/zh-cn/problem/permutations-ii/?
天街孤独
·
2020-02-13 23:18
46. Majority Element
题目https://www.
lintcode
.com/problem/majority-element/description?
严海翔
·
2020-02-13 18:55
Building Post Office I & II (
Lintcode
574, 573)
先来看BuildingPostOfficeII:http://www.
lintcode
.com/en/problem/build-post-office-ii/#该题有如下几个要点需要记:一,建立一个struct
stepsma
·
2020-02-13 10:48
lintcode
落单的数(|,||,|||)
样例给出[1,2,2,1,3,4,3],返回4题目链接:http://www.
lintcode
.com/zh-cn/problem/single-number/将数组的数全部做异或,最后得到的数就是要找的数
yzawyx0220
·
2020-02-13 03:46
LintCode
Maximal Square
Givena2Dbinarymatrixfilledwith0'sand1's,findthelargestsquarecontainingall1'sandreturnitsarea.样例Forexample,giventhefollowingmatrix:10100101111111110010Return4.解题思路初始思路是判断对角方向以及相邻的两个数,运行结果错误,然后查看错误发现需要判
Arnold134777
·
2020-02-12 15:22
Lintcode
166 Nth to Last Node in List solution 题解
【题目链接】www.
lintcode
.com/en/problem/nth-to-last-node-in-list/【题目解析】这一道找倒数第n个结点的链表题,可用双指针做。由于
程风破浪会有时
·
2020-02-12 13:13
LintCode
-66.二叉树的前序遍历
题目描述给出一棵二叉树,返回其节点值的前序遍历。样例给出一棵二叉树{1,#,2,3},1\2/3返回[1,2,3].解答思路前序遍历二叉树代码/***DefinitionofTreeNode:*publicclassTreeNode{*publicintval;*publicTreeNodeleft,right;*publicTreeNode(intval){*this.val=val;*this
悠扬前奏
·
2020-02-12 04:18
Lintcode
112 Remove Duplicates From Sorted List solution 题解
【题目链接】www.
lintcode
.com/en/problem/remove-duplicates-from-sorted-list/【题目解析】根据题目要求,我们需要删除链表
程风破浪会有时
·
2020-02-12 01:41
lintCode
题解(9)
标签(空格分隔):
lintCode
FizzBuzz问题描述:给你一个整数n.从1到n按照下面的规则打印每个数:如果这个数被3整除,打印fizz.如果这个数被5整除,打印buzz.如果这个数能同时被3和5
Sivin
·
2020-02-12 01:53
LintCode
102. Linked List Cycle
題目:Givenalinkedlist,determineifithasacycleinit.思路:快慢指針代碼:classSolution{public:/**@paramhead:Thefirstnodeoflinkedlist.*@return:Trueifithasacycle,orfalse*/boolhasCycle(ListNode*head){//writeyourcodehere
aammyytt
·
2020-02-11 23:23
上一页
46
47
48
49
50
51
52
53
下一页
按字母分类:
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
其他