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
Wood Cut
http://www.
lintcode
.com/zh-cn/problem/wood-cut/有一些原木,现在想把这些木头切割成一些长度相同的小段木头,需要得到的小段的数目至少为k。
weixin_33701251
·
2020-06-28 03:19
lintcode
644 镜像数字
模拟:从左到右扫一遍,看对应位置是不是mirrorword.classSolution{public:/***@paramnum:astring*@return:trueifanumberisstrobogrammaticorfalse*///两个数字中心对称且它们是镜像数字,即旋转180度等于另一个数字boolisStrobogrammatic(string&num){//writeyourco
weixin_30947043
·
2020-06-28 02:12
(前缀和数组)
lintcode
642. Moving Average from Data Stream
给定长度的slidingwindow,求出数字流在这个window区间的平均值:解法:前缀和数组:index:1234d:11035sum:1111419sum[i]=d[1]+d[2]+...+d[i]d[x]+d[x+1]+...+d[y]=sum[y]-sum[x-1]优化:使用滚动数组来优化空间复杂度。对于滑动窗口为3时,只存4个,即可以将下标变为index%=40123456789012
weixin_30947043
·
2020-06-28 02:12
(BST, 二叉树,递归)
lintcode
628.
/***DefinitionofTreeNode:*classTreeNode{*public:*intval;*TreeNode*left,*right;*TreeNode(intval){*this->val=val;*this->left=this->right=NULL;*}*}*/classSolution{public:/***@paramroot:therootofbinarytre
weixin_30947043
·
2020-06-28 02:12
(分类讨论, 情景模拟, 区间类型)
lintcode
640. One Edit Distance, leetcode 388,intcode 645. 13. 12. 659. 660...
找特殊情况,分类讨论:三种情况1)两个字符串的长度之差大于1直接返回false;2)长度之差等于1,判断长的字符串删掉不一样的字符,剩余的字符串是否相同;3)长度之差等于0,判断不相同的字符个数,若超过一个返回false。classSolution{public:/***@params:astring*@paramt:astring*@return:trueiftheyarebothoneedit
weixin_30947043
·
2020-06-28 02:12
(哈希表,滑动窗口,栈)
lintcode
646
classSolution{public:/***@params:astring*@return:it'sindex*/intfirstUniqChar(string&s){//writeyourcodeherevectorcnt(256,0);for(inti=0;ifindAnagrams(string&s,string&p){//writeyourcodehere//返回所有同构串的首地址v
weixin_30947043
·
2020-06-28 02:12
lintcode
_182. 删除数字
给出一个字符串A,表示一个n位正整数,删除其中k位数字,使得剩余的数字仍然按照原来的顺序排列产生一个新的正整数。找到删除k个数字之后的最小正整数。N"121"。由于删完一位后,前一位可能比后一位要大了,如"5631"若要继续删除,则应先删除“6”->"531"再删除"5"->"31"。所以考虑可以使用双重循环,外循环迭代删除次数,内循环遍历当前字符串内循环若从字符串初始开始搜索,时间复杂度为O(N
weixin_30947043
·
2020-06-28 02:41
lintcode
求n!中末尾0 的个数
我们只需要考虑哪些数相乘可以得到10即可,因为2*5=10,因此我们只需要找到2和5的个数的较小的一个值,因为能被2整除的数多于能被5整除的数,因此题目转换成包含因子5的个数。代码如下:classSolution{public://paramn:descriptionofn//return:descriptionofreturnlonglongtrailingZeros(longlongn){lo
yzawyx0220
·
2020-06-28 02:18
LintCode
- 翻转二叉树(普通)
版权声明:本文为博主原创文章,未经博主允许不得转载。难度:容易要求:翻转一棵二叉树样例11/\/\23=>32/\44思路:/***@paramroot:aTreeNode,therootofthebinarytree*@return:nothing*/publicvoidinvertBinaryTree(TreeNoderoot){if(root==null){return;}TreeNoden
柒黍
·
2020-06-28 02:25
lintcode
-medium-Rehashing
Thesizeofthehashtableisnotdeterminateattheverybeginning.Ifthetotalsizeofkeysistoolarge(e.g.size>=capacity/10),weshoulddoublethesizeofthehashtableandrehasheverykeys.Sayyouhaveahashtablelookslikebelow:s
weixin_30824599
·
2020-06-28 01:05
LintCode
Coins in a Line III
原题链接在这里:http://www.
lintcode
.com/en/problem/coins-in-a-line-iii/题目:Therearencoinsinaline.Twoplayerstaketurnstotakeacoinfromoneoftheendsofthelineuntiltherearenomorecoinsleft.Theplayerwiththelargeramount
weixin_30745641
·
2020-06-28 00:40
[容易]数组剔除元素后的乘积
题目来源:http://www.
lintcode
.com/zh-cn/problem/product-of-array-exclude-itself/方法1:直接法可以accept的程序如下:1classSolution
weixin_30685047
·
2020-06-27 23:29
[
LintCode
] 395. Coins in a Line 2_Medium tag: Dynamic Programming, 博弈
DescriptionTherearencoinswithdifferentvalueinaline.Twoplayerstaketurnstotakeoneortwocoinsfromleftsideuntiltherearenomorecoinsleft.Theplayerwhotakethecoinswiththemostvaluewins.Couldyoupleasedecidethefi
weixin_30673715
·
2020-06-27 23:17
Word Search II
http://www.
lintcode
.com/en/problem/word-search-ii/packagecom.
LintCode
.Word;importjava.util.ArrayList;
天街孤独
·
2020-06-27 22:20
给定 2 个正整数 a, b,a 和 b 最多可能有 40 位,求出 a + b 的和(C语言实现)
最近参加一个编程比赛,里面有个一些题库,这个题目就是其中之一.当然,如果想锻炼自己的编程水平,可以去
lintcode
或者其他的网站上去刷题.自信满满的我看到花了一个多小时才写出来,实在是汗颜.本来实现使用
weixin_30578677
·
2020-06-27 21:11
LeetCode javascript 解题列表
本文不再更新,如果需要查看解题,直接进入https://github.com/Arnold134777/LeetCode-
LintCode
/tree/master/javascript查看。
Arnold134777
·
2020-06-27 21:31
LintCode
182. 删除数字
182.删除数字给出一个字符串A,表示一个n位正整数,删除其中k位数字,使得剩余的数字仍然按照原来的顺序排列产生一个新的正整数。找到删除k个数字之后的最小正整数。N=0;--i){if(A[i]=start;--i){if(A[i]=start;--i){//在这个范围里面取第一个最小值if(A[i]<=A[index])index=i;}stringres="";res.push_back(A[
weixin_30463341
·
2020-06-27 20:02
[
Lintcode
]50. Product of Array Exclude Itself
50.ProductofArrayExcludeItselfDescriptionGivenanintegersarrayA.DefineB[i]=A[0]*…*A[i-1]*A[i+1]*…*A[n-1],calculateBWITHOUTdivideoperation.OutputBExampleForA=[1,2,3],return[6,3,2].我的代码classSolution:"""@
weixin_30379973
·
2020-06-27 18:06
lintcode
-182-删除数字
182-删除数字给出一个字符串A,表示一个n位正整数,删除其中k位数字,使得剩余的数字仍然按照原来的顺序排列产生一个新的正整数。找到删除k个数字之后的最小正整数。NA[i]&&newSize
weixin_30362233
·
2020-06-27 18:37
Hex Conversion [
LintCode
naive]
DescriptionGivenadecimalnumbernandanintegerk,Convertdecimalnumberntobase-k.1.09){s=(char)(temp-10+'A')+s;}else{s=temp+s;}n=n/k;}returns;}}思路二:publicclassSolution{/***@paramn:adecimalnumber*@paramk:aIn
weixin_30340819
·
2020-06-27 18:53
lintcode
-170-旋转链表
旋转链表给定一个链表,旋转链表,使得每个节点向右移动k个位置,其中k是一个非负数样例给出链表1->2->3->4->5->null和k=2返回4->5->1->2->3->null标签基本实现链表思路利用
lintcode
weixin_30265103
·
2020-06-27 15:33
LintCode
-搜索旋转排序数组
假设有一个排序的按未知的旋转轴旋转的数组(比如,0124567可能成为4567012)。给定一个目标值进行搜索,如果在数组中找到目标值返回数组中的索引位置,否则返回-1。你可以假设数组中不存在重复的元素。您在真实的面试中是否遇到过这个题?Yes样例给出[4,5,1,2,3]和target=1,返回2给出[4,5,1,2,3]和target=0,返回-1标签Expand相关题目Expand分析:二分
wangyuquan
·
2020-06-27 13:33
面试
LintCode
-旋转链表
给定一个链表,旋转链表,使得每个节点向右移动k个位置,其中k是一个非负数样例给出链表1->2->3->4->5->null和k=2返回4->5->1->2->3->null分析:链表的基本操作代码:/***Definitionforsingly-linkedlist.*structListNode{*intval;*ListNode*next;*ListNode(intx):val(x),next
wangyuquan
·
2020-06-27 13:33
面试
Binary Tree Path Sum IV
https://www.
lintcode
.com/problem/binary-tree-path-sum-iv/descriptionimportjava.util.Arrays;publicclassSolution
天街孤独
·
2020-06-27 13:04
动态规划_最大子数组|||_1
【思路】参考:
LintCode
:MaximumSubarrayIII假设给定数组共有N个元素,需要找到K个不重合的子数组使其和最大。
vye_csdn
·
2020-06-27 11:46
数据结构与算法
Lintcode
134 Lru Cache solution 题解
【题目描述】DesignandimplementadatastructureforLeastRecentlyUsed(LRU)cache.Itshouldsupportthefollowingoperations:getandset.get(key)-Getthevalue(willalwaysbepositive)ofthekeyifthekeyexistsinthecache,otherwis
程风破浪会有时
·
2020-06-27 10:04
LintCode
467 [Complete Binary Tree]
原题检查一棵二叉树是不是完全二叉树。完全二叉树是指一棵树除了最后一层,其它层上节点都有左右孩子,最后一层上,所有节点都必须尽量靠左。样例1/\23/4是完全二叉树1/\23\4不是完全二叉树解题思路理清思路:满二叉树:每个节点都有0或是2个孩子。完全二叉树:所有的叶子都拥有同的深度,所有的内部节点拥有2个孩子BFS-广度优先搜索,对于一棵树,层层遍历,把每层的节点从左向右依此加入Stack,然后把
Jason_Yuan
·
2020-06-27 10:29
LintCode
寻找旋转排序数组中的最小值
题目假设一个旋转排序的数组其起始位置是未知的(比如0124567可能变成是4567012)。你需要找到其中最小的元素。你可以假设数组中不存在重复的元素。样例给出[4,5,6,7,0,1,2]返回0分析很简单的二分法,多加了两种情况代码publicclassSolution{/***@paramnums:arotatedsortedarray*@return:theminimumnumberinth
六尺帐篷
·
2020-06-27 10:23
lintcode
----数组剔除元素后的乘积
vectorproductExcludeItself(vector&nums){//writeyourcodeherevectorres;longlongtem=1;intflag=0;for(intj=0;j
步行者之神
·
2020-06-27 05:23
lintcode
LintCode
382 [Triangle Count]
原题给定一个整数数组,在该数组中,寻找三个数,分别代表三角形三条边的长度,问,可以寻找到多少组这样的三个数来组成三角形?样例例如,给定数组S={3,4,6,7},返回3其中我们可以找到的三个三角形为:{3,4,6}{3,6,7}{4,6,7}给定数组S={4,4,4,4},返回4其中我们可以找到的四个三角形为:{4(1),4(2),4(3)}{4(1),4(2),4(4)}{4(1),4(3),4
Jason_Yuan
·
2020-06-27 04:37
longest substring without repeat characters(leetcode3,
lintcode
384)
Givenastring,findthelengthofthe**longestsubstring**withoutrepeatingcharacters.Examples:Given"abcabcbb",theansweris"abc",whichthelengthis3.Given"bbbbb",theansweris"b",withthelengthof1.Given"pwwkew",the
wangpancn
·
2020-06-27 04:24
LintCode
#80FindMedian(利用快排找中位数)
题目:用时间复杂度为o(nlogn)的算法,给定一个未排序的整数数组,找到其中位数。中位数是排序后数组的中间值,如果数组的个数是偶数个,则返回排序后数组的第N/2个数。难度:Easy思路:利用快排,pivot存放的位置index,如果index=(N-1)/2,说明pivot前面有index个元素小于或者pivot,每次递归快排,判断index的值与(N-1)/2的大小关系代码:这里的快排是直接用
HAHAHA-
·
2020-06-27 04:30
LeetCode
LintCode
: 连续子数组求和
LintCode
:连续子数组求和需要考虑很多种情况,也是看了数据才知道逻辑哪里不对,感觉自己考虑问题很不全面。
zyaphone
·
2020-06-27 03:21
lintcode
python
Lintcode
:旋转链表
描述给定一个链表,旋转链表,使得每个节点向右移动k个位置,其中k是一个非负数样例给出链表1->2->3->4->5->null和k=2返回4->5->1->2->3->null思路:先算出链表的长度len,然后k%len,可以得出实际移动的次数。然后使用一个快慢指针,快的先走k步,然后一起移动,知道快的指针的next为null,停止。这时慢指针的next节点就是旋转后的头节点,然后指针重新设置下,
cosmos_lee
·
2020-06-27 03:18
LeetCode
字符串操作
LintCode
P158判断两个字符串是否为变位词用sort对字符串排序后,判断是否相等即可。
左岸cpx
·
2020-06-27 02:26
刷刷刷
不用“+”运算符,实现A+B运算
来源:
lintcode
A+B问题解决方法:位操作六种按位操作符:按位与:&按位或:|按位取反:~按位异或:^按位左移:>(对无符号数,高位补0,有符号数,各编译器处理方法不一样,有的补符号位(算术右移)
左岸cpx
·
2020-06-27 02:25
刷刷刷
lintcode
删除数字
lintcode
删除数字给出一个字符串A,表示一个n位正整数,删除其中k位数字,使得剩余的数字仍然按照原来的顺序排列产生一个新的正整数。找到删除k个数字之后的最小正整数。
bapijun
·
2020-06-27 02:31
C与C++
Lintcode
50. Product of Array Exclude Itself
Q:GivenanintegersarrayA.DefineB[i]=A[0]*...*A[i-1]*A[i+1]*...*A[n-1],calculateBWITHOUTdivideoperation.ExampleForA=[1,2,3],return[6,3,2].Code:思路很简单,第一遍算前n-1项累计的乘积,第一项是1,第二项是n(0),第二项是n(0)n(1),第n项是1n(0)n
weiyongzhiaaa
·
2020-06-27 02:17
LintCode
-剑指Offer-(50)数组剔除元素后的乘积
classSolution{public:/***@paramA:GivenanintegersarrayA*@return:AlonglongarrayBandB[i]=A[0]*...*A[i-1]*A[i+1]*...*A[n-1]*/vectorproductExcludeItself(vector&nums){//writeyourcodeherevectortmpv;for(inti=
风顺水流
·
2020-06-27 01:44
LintCode
OJ
lintcode
最后一个单词的长度
给定一个字符串,包含大小写字母、空格'',请返回其最后一个单词的长度。如果不存在最后一个单词,请返回0。注意事项一个单词的界定是,由字母组成,但不包含任何的空格。您在真实的面试中是否遇到过这个题?Yes样例给定s="HelloWorld",返回5。classSolution{public:/***@paramsAstring*@returnthelengthoflastword*/intlengt
zhaozhengcoder
·
2020-06-27 01:02
246. Strobogrammatic Number
packageLeetCode_246/***246.StrobogrammaticNumber*(lockedbyLeetcode)*https://www.
lintcode
.com/problem/
johnny_zhao
·
2020-06-27 00:00
**剑指offer-70-53 0-n-1中缺失的数字
如果原来的数组无序,那么hashO(n)https://www.
lintcode
.com/problem/missing-number/descriptionclassSolution{public:/
Z-Pilgrim
·
2020-06-27 00:06
剑指Offer
【Leetcode】最接近和子数组
这次是
Lintcode
的题目:http://www.
lintcode
.com/zh-cn/problem/subarray-sum-closest/给一个数组和k,找出一个子数组,和最接近k,如果有多个返回任意一个
绝世好阿狸
·
2020-06-26 23:34
leetcode
LintCode
395. Coins in a Line II
395.CoinsinaLineIITherearencoinswithdifferentvalueinaline.Twoplayerstaketurnstotakeoneortwocoinsfromleftsideuntiltherearenomorecoinsleft.Theplayerwhotakethecoinswiththemostvaluewins.Couldyoupleasedeci
CS番茄
·
2020-06-26 21:50
Leetcode_DP
Memory
Search
博弈论
LintCode
394. Coins in a Line
DescriptionTherearencoinsinaline.Twoplayerstaketurnstotakeoneortwocoinsfromrightsideuntiltherearenomorecoinsleft.Theplayerwhotakethelastcoinwins.Couldyoupleasedecidethefirstplaywillwinorlose?Haveyoume
CS番茄
·
2020-06-26 21:49
Leetcode_DP
Memory
Search
博弈论
LintCode
刷题(入门篇)
最近在玩
LintCode
上面的算法题。下面分享一下部分题目的答案。如果其他同学有更好的答案,可以和我交流讨论,本人菜鸟一个,各位大佬多指点。
秋名山小尼玛
·
2020-06-26 19:44
LintCode
lintcode
(402)连续子数组求和
描述:给定一个整数数组,请找出一个连续子数组,使得该子数组的和最大。输出答案时,请分别返回第一个数字和最后一个数字的下标。(如果两个相同的答案,请返回其中任意一个)样例:给定[-3,1,3,-3,4],返回[1,4].思路:逐个累加求和,记录最小值和最大值的位置,最小值的下一位是丘壑最大值的起点,最大值[(sum-min)的最大值]的位置是和最大值的终点publicclassSolution{/*
sunday0904
·
2020-06-26 15:01
lintcode
(170)旋转链表
描述:给定一个链表,旋转链表,使得每个节点向右移动k个位置,其中k是一个非负数样例:给出链表1->2->3->4->5->null和k=2返回4->5->1->2->3->null思路:借用Arraylist/***Definitionforsingly-linkedlist.*publicclassListNode{*intval;*ListNodenext;*ListNode(intx){*v
sunday0904
·
2020-06-26 15:00
lintcode
1119 三个数的最大乘积(java实现)
1.描述给定一个整数数组,找到三个元素,使乘积最大,返回该积。注:数组的长度范围为[3,10^4],所有的元素范围为[-1000,1000]。任意三个元素的积不会超过32位有符号整数的范围。样例样例1:输入:[1,2,3]输出:6样例2:输入:[1,2,3,4]输出:242.代码publicintmaximumProduct(int[]nums){if(nums.lengthmax1){max3=
stay_the_course
·
2020-06-26 14:47
从零开始写算法
lintcode
算法题之219-在排序链表中插入一个节点
219.在排序链表中插入一个节点在链表中插入一个节点。样例样例1:输入:head=1->4->6->8->null,val=5输出:1->4->5->6->8->null样例2:输入:head=1->null,val=2输出:1->2->null代码区:/***DefinitionforListNode*publicclassListNode{*intval;*ListNodenext;*List
evolution_language
·
2020-06-26 13:35
算法
lintcode
java
上一页
32
33
34
35
36
37
38
39
下一页
按字母分类:
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
其他