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
Leetcode每日一题
LeetCode每日一题
:anagrams
问题描述Givenanarrayofstrings,returnallgroupsofstringsthatareanagrams.Note:Allinputswillbeinlower-case.问题分析这题不太理解:Anagrams—LeetCode-CodeGanker-博客频道-CSDN.NET附上参考博客这是一道很经典的面试题了,在cc150里面也有,就是把一个数组按照易位构词分类。易位
yoshino
·
2020-06-24 07:34
LeetCode每日一题
:edit distance
问题描述Giventwowordsword1andword2,findtheminimumnumberofstepsrequiredtoconvertword1toword2.(eachoperationiscountedas1step.)Youhavethefollowing3operationspermittedonaword:a)Insertacharacterb)Deleteacharac
yoshino
·
2020-06-23 22:40
LeetCode每日一题
:3.3合并排序的数组(八十三)
合并排序的数组一、LeetCode题解瞧一瞧~博健的LeetCode题解:Gitbook版本传送门博健的LeetCode题解:CSDN传送门有趣的CSS:Gitbook传送门前端进阶笔记:Gitbook传送门二、算法题题目给定两个排序后的数组A和B,其中A的末端有足够的缓冲空间容纳B。编写一个方法,将B合并入A并排序。初始化A和B的元素数量分别为m和n。示例:输入:A=[1,2,3,0,0,0],
余光、
·
2020-06-23 21:17
#
LeetCode题解系列
leetcode算法练习
leetcode每日一题
有效括号的嵌套深度//1111.有效括号的嵌套深度/*有效括号字符串定义:对于每个左括号,都能找到与之对应的右括号,反之亦然。详情参见题末「有效括号字符串」部分。
未入门萌新
·
2020-06-22 09:44
LeetCode每日一题
206.反转链表
206.反转一个单链表。示例:输入:1->2->3->4->5->NULL输出:5->4->3->2->1->NULL来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/reverse-linked-list著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。昨天困难级的K个一组反转链表,着实费脑子,需要考虑很多的细节,一不留神就是
爱喝茶的菜鸟
·
2020-06-22 04:47
【
leetcode每日一题
】149.Max Points on a line
题目:Givennpointsona2Dplane,findthemaximumnumberofpointsthatlieonthesamestraightline.解析:题目要求是给定n个2维的点,求出总共有多少个点在同一条直线上。由数学知识可知,给定三个点a,b,c,如果三个点在一条直线上,则a和b的斜率与c和d的斜率是相同的。用哈希表来做,针对每个点,求出其余所有点与它的斜率,找出最大值。然
Kevin_zhai
·
2020-06-21 23:27
算法与数据结构
leetcode解题笔记
LeetCode每日一题
104. 二叉树的最大深度
104.二叉树的最大深度TagTreeDFSDifficultyEasyLinkhttps://leetcode-cn.com/problems/maximum-depth-of-binary-tree/分析使用深度优先搜索,沿着树的深度遍历树的节点。第一种是递归方法递归调用的参数是通过栈空间传递的,在调用过程中会占用线程的栈资源并且只有走到最后的结束点函数才能依次退出,在这之前,占用的栈空间一直
AdamZhouSE
·
2020-06-21 20:48
LeetCode每日一题
111. 二叉树的最小深度
111.二叉树的最小深度TagTreeDFSDifficultyEasyLinkhttps://leetcode-cn.com/problems/minimum-depth-of-binary-tree/分析与求二叉树的最大深度类似,只是要注意特例[1,2]的深度是2而不是1,因为题目要求是根节点到叶节点的最短距离,也就是是如果根节点的左子树为空或右子树为空的时候,最小深度和最大深度是一致的。题解
AdamZhouSE
·
2020-06-21 20:48
DP问题,由浅入深,附java解法
今天的
leetcode每日一题
又刷到了DP问题,而且是hard级别的,着实伤脑筋,姑且回顾一下之前遇到的DP问题,温故而知新。
EdwardWH
·
2020-06-21 19:00
leetcode每日一题
-移除元素
给你一个数组nums和一个值val,你需要原地移除所有数值等于val的元素,并返回移除后数组的新长度。不要使用额外的数组空间,你必须仅使用O(1)额外空间并原地修改输入数组。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。由题目可知的条件和限制:1.原地修改2.不能使用额外的数组空间,空间复杂度为O(1)3.元素的顺序可以改变主要思路:将不等于val的值往前放,元素交换位置~双指针fu
好好学习
·
2020-06-21 02:01
数组
leetcode
双指针
leetcode每日一题
——6月6
问题给定一个未排序的整数数组,找出最长连续序列的长度。要求算法的时间复杂度为O(n)。输入:[100,4,200,1,3,2]输出:4解释:最长连续序列是[1,2,3,4]。它的长度为4。通过并查集对这道题进行求解classSolution{public:undered_mapF;intfather(intx){if(F.count(x)==0)returnx;if(F[x]!=x)F[x]=fa
吕店老板
·
2020-06-06 07:00
leetcode每日一题
6月五号
题目输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。输入:matrix=[[1,2,3],[4,5,6],[7,8,9]]输出:[1,2,3,6,9,8,7,4,5]classSolution{public:vectorspiralOrder(vector>&matrix){if(matrix.size()==0||matrix[0].size()==0)return{};intro
吕店老板
·
2020-06-06 00:00
leetcode每日一题
——六月4号
题目238除自身以外的所有乘积给你一个长度为n的整数数组nums,其中n>1,返回输出数组output,其中output[i]等于nums中除nums[i]之外其余各元素的乘积。输入:[1,2,3,4]输出:[24,12,8,6]提示:题目数据保证数组之中任意元素的全部前缀元素和后缀(甚至是整个数组)的乘积都在32位整数范围内。说明:请不要使用除法,且在O(n)时间复杂度内完成此题。一利用两个数组
吕店老板
·
2020-06-04 23:00
leetcode每日一题
六月2日
题目求1+2+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。如果不加以限制则可以采用递归的方式来做classSolution{public:intsumNums(intn){returnn==0?0:n+sumNums(n-1);}};利用&&的短路性质classSolution{public:intsumNums(
吕店老板
·
2020-06-02 22:00
leetcode每日一题
-974. 和可被 K 整除的子数组
974.和可被K整除的子数组给定一个整数数组A,返回其中元素之和可被K整除的(连续、非空)子数组的数目。示例:输入:A=[4,5,0,-2,-3,1],K=5输出:7解释:有7个子数组满足其元素之和可被K=5整除:[4,5,0,-2,-3,1],[5],[5,0],[5,0,-2,-3],[0],[0,-2,-3],[-2,-3]来源:力扣(LeetCode)链接:https://leetcode
一学子
·
2020-05-27 15:49
leetcode刷题
LeetCode每日一题
5月27日 LeetCode974. 可被K整除的子数组
问题描述:给定一个整数数组A,返回其中元素之和可被K整除的(连续、非空)子数组的数目。来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/subarray-sums-divisible-by-k示例:输入:A=[4,5,0,-2,-3,1],K=5输出:7解释:有7个子数组满足其元素之和可被K=5整除:[4,5,0,-2,-3,1],[5],[5,
青日五月
·
2020-05-27 10:47
LeetCode刷题记录
leetcode
算法
数据结构
leetcode每日一题
5.20每个元音包含偶数次的最长字符串
给你一个字符串s,请你返回满足以下条件的最长子字符串的长度:每个元音字母,即‘a’,‘e’,‘i’,‘o’,‘u’,在子字符串中都恰好出现了偶数次。示例1:输入:s=“eleetminicoworoep”输出:13解释:最长子字符串是“leetminicowor”,它包含e,i,o各2个,以及0个a,u。示例2:输入:s=“leetcodeisgreat”输出:5解释:最长子字符串是“leetc”
陌丶尘
·
2020-05-20 11:42
leetcode
leetcode每日一题
-560. 和为K的子数组
560.和为K的子数组给定一个整数数组和一个整数k,你需要找到该数组中和为k的连续的子数组的个数。举例输入:nums=[1,1,1],k=2输出:2,[1,1]与[1,1]为两种不同的情况。思路(参考题解中@天使爆破组):暴力解法:枚举所有子数组,i为子数组开端,j为子数组结束,累计nums[i]+...+nums[j]=k?,代码如下:intcount=0;for(inti=0;imap;map
一学子
·
2020-05-15 20:18
leetcode刷题
学习
leetcode每日一题
5.15和为K的子数组
给定一个整数数组和一个整数k,你需要找到该数组中和为k的连续的子数组的个数。示例1:输入:nums=[1,1,1],k=2输出:2,[1,1]与[1,1]为两种不同的情况。说明:数组的长度为[1,20,000]。数组中元素的范围是[-1000,1000],且整数k的范围是[-1e7,1e7]。思路:这题我们采用两种做法,第一种暴力法,固定左边界,遍历至数组结束。第二种前缀和,首先我们获得所有的前缀
陌丶尘
·
2020-05-15 10:13
leetcode
LeetCode每日一题
5月15日 LeetCode560,和为k的子数组
问题描述:给定一个整数数组和一个整数k,你需要找到该数组中和为k的连续的子数组的个数。来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/subarray-sum-equals-k示例1:输入:nums=[1,1,1],k=2输出:2,[1,1]与[1,1]为两种不同的情况。说明:数组的长度为[1,20,000]。数组中元素的范围是[-1000,1
青日五月
·
2020-05-15 09:35
LeetCode刷题记录
leetcode
算法
数据结构
LeetCode每日一题
之 二叉树的”之“字形打印
image题目:请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推。算法地址我感觉可以自己先做做,你说呢!!!!!!解题思路这个和上一道二叉树的行数打印很相像,只不过这道题更改了每一行的打印顺序。给出一个树典型二叉树那么这道题要求的打印顺序就是,FECADHGMB我们怎么才能按照顺序打印出来呢。如果按照上一
ZSACH
·
2020-04-21 13:45
LeetCode每日一题
:add two numbers
问题描述Youaregiventwolinkedlistsrepresentingtwonon-negativenumbers.Thedigitsarestoredinreverseorderandeachoftheirnodescontainasingledigit.Addthetwonumbersandreturnitasalinkedlist.Input:(2->4->3)+(5->6->4
yoshino
·
2020-04-13 18:23
LeetCode每日一题
:largest rectangle in histogram
问题描述Givennnon-negativeintegersrepresentingthehistogram'sbarheightwherethewidthofeachbaris1,findtheareaoflargestrectangleinthehistogram.1Aboveisahistogramwherewidthofeachbaris1,givenheight=[2,1,5,6,2,3
yoshino
·
2020-04-13 03:15
LeetCode每日一题
:买卖股票的最好时机 2
问题描述Sayyouhaveanarrayforwhichtheielementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteasmanytransactionsasyoulike(ie,buyoneandselloneshareofthestockmultipletimes)
yoshino
·
2020-04-12 07:22
LeetCode每日一题
:加油站问题
问题描述ThereareNgasstationsalongacircularroute,wheretheamountofgasatstationiisgas[i].Youhaveacarwithanunlimitedgastankanditcostscost[i]ofgastotravelfromstationitoitsnextstation(i+1).Youbeginthejourneywit
yoshino
·
2020-04-12 04:34
LeetCode每日一题
:trapping rain water
问题描述Givennnon-negativeintegersrepresentinganelevationmapwherethewidthofeachbaris1,computehowmuchwateritisabletotrapafterraining.Forexample,Given[0,1,0,2,1,0,1,3,2,1,2,1],return6.问题分析这题可以用动态规划做,设left[i
yoshino
·
2020-04-12 03:02
LeetCode每日一题
:在同一直线上点的最大个数
问题描述Givennpointsona2Dplane,findthemaximumnumberofpointsthatlieonthesamestraightline.问题分析本题求给定2D平面上的最多有几个点在同一直线上。这道题没有好的算法,一般用穷举法即可。穷举所有的点a计算其余点和a的斜率,存储在HashMap中计算和a点有多少个重合点dup计算和a具有相同x坐标的点数vtl(垂直于x轴斜率
yoshino
·
2020-04-12 02:01
团队交流记录 - 2020-04
团队制定一个活动帮大家进阶:每周二、周四集体刷
leetcode每日一题
,周五总结分享。
Apolis
·
2020-04-12 00:00
团队交流记录 - 2020-04
团队制定一个活动帮大家进阶:每周二、周四集体刷
leetcode每日一题
,周五总结分享。
apolis
·
2020-04-12 00:00
LeetCode每日一题
: 322. 零钱兑换
322.零钱兑换标签:动态规划给定不同面额的硬币coins和一个总金额amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回-1。示例1:输入:coins=[1,2,5],amount=11输出:3解释:11=5+5+1示例2:输入:coins=[2],amount=3输出:-1思路'''1.观察到题目主要问题可以划分成规模更小子问题,采用动
pao哥
·
2020-04-11 19:18
LeetCode每日一题
:search insert position
问题描述Givenasortedarrayandatargetvalue,returntheindexifthetargetisfound.Ifnot,returntheindexwhereitwouldbeifitwereinsertedinorder.Youmayassumenoduplicatesinthearray.Herearefewexamples.[1,3,5,6],5→2[1,3,
yoshino
·
2020-04-11 11:29
LeetCode每日一题
:rotate list
问题描述Givenalist,rotatethelisttotherightbykplaces,wherekisnon-negative.Forexample:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.问题分析这题很麻烦,n可能很大,需要取余才能确定分界点,链表操作没有什么难点。代码实现publicListNoderotate
yoshino
·
2020-04-10 17:13
LeetCode每日一题
:maximal rectangle
问题描述Givena2Dbinarymatrixfilledwith0'sand1's,findthelargestrectanglecontainingallonesandreturnitsarea.问题分析这道题可以说是上一道的延伸,把一维数组改成了二维数组,我们可以使用上一题的方法,把二维数组的每一行作为输入,输入的高度就是该行向上连在一起的‘1’高度,循环row行最后取最大值即可。代码实现
yoshino
·
2020-04-10 16:52
LeetCode每日一题
:拷贝带随机指针的链表
问题描述Alinkedlistisgivensuchthateachnodecontainsanadditionalrandompointerwhichcouldpointtoanynodeinthelistornull.Returnadeepcopyofthelist.问题分析深拷贝一个链表,不同于别的链表,这个链表有一个随机的指针random,指向随机的位置,所以对于一个节点,除了要处理他前后
yoshino
·
2020-04-10 08:29
LeetCode每日一题
:判断是不是平衡二叉树
问题描述Givenabinarytree,determineifitisheight-balanced.Forthisproblem,aheight-balancedbinarytreeisdefinedasabinarytreeinwhichthedepthofthetwosubtreesofeverynodeneverdifferbymorethan1.问题分析判断一棵树是不是平衡二叉树,用递
yoshino
·
2020-04-10 04:35
LeetCode每日一题
:spiral matrix i
问题描述Givenamatrixofmxnelements(mrows,ncolumns),returnallelementsofthematrixinspiralorder.Forexample,Giventhefollowingmatrix:[[1,2,3],[4,5,6],[7,8,9]]Youshouldreturn[1,2,3,6,9,8,7,4,5].问题分析不需要什么算法,螺旋打印即
yoshino
·
2020-04-09 18:52
LeetCode每日一题
:数组中的第 K 个最大元素
题目:在未排序的数组中找到第k个最大的元素。请注意,你需要找的是数组排序后的第k个最大的元素,而不是第k个不同的元素。示例1:输入:[3,2,1,5,6,4]和k=2输出:5示例2:输入:[3,2,3,1,2,4,5,5,6]和k=4输出:4说明:你可以假设k总是有效的,且1≤k≤数组的长度。方法一:排序算法:1、对数组进行从小到大排序;2、将数组按从大到小的顺序入队;3、将第k个元素出队返回;代
不会Java怎么找女朋友
·
2020-04-08 18:47
LeetCode
LeetCode每日一题
:数组最长连续元素的个数
问题描述Givenanunsortedarrayofintegers,findthelengthofthelongestconsecutiveelementssequence.Forexample,Given[100,4,200,1,3,2],Thelongestconsecutiveelementssequenceis[1,2,3,4].Returnitslength:4.Youralgorit
yoshino
·
2020-04-08 15:25
LeetCode每日一题
:roman to integer
问题描述Givenaromannumeral,convertittoaninteger.Inputisguaranteedtobewithintherangefrom1to3999.问题分析罗马数字转int,了解规则后还是很容易的I1V5X10L50C100D500M1000相同的数字连写、所表示的数等于这些数字相加得到的数、如:Ⅲ=3;小的数字在大的数字的右边、所表示的数等于这些数字相加得到的数
yoshino
·
2020-04-07 20:42
LeetCode每日一题
:链表直接插入排序
问题描述Sortalinkedlistusinginsertionsort.问题分析用插入排序进行链表排序,没什么好说的代码实现publicListNodeinsertionSortList(ListNodehead){ListNodelistNode=newListNode(Integer.MIN_VALUE);ListNodecur=head;ListNodepre=listNode;//用最
yoshino
·
2020-04-07 04:44
LeetCode每日一题
:通过中序和后序建立二叉树
问题描述Giveninorderandpostordertraversalofatree,constructthebinarytree.Note:Youmayassumethatduplicatesdonotexistinthetree.问题分析通过中序和后序来建立二叉树,不用考虑数组中有重复数字。通过后序我们可以找到根节点(最后一个),用递归建树即可。代码实现publicTreeNodebuil
yoshino
·
2020-04-07 02:35
LeetCode每日一题
:plus one
问题描述Givenanumberrepresentedasanarrayofdigits,plusonetothenumber.问题分析这道题目的意思蛮难理解的,大概的意思是digits数组{1,2,3,4},组成一个数1234,把这个数+1=1235用数组返回1235结果,若结果位数变多,那么直接溢出。这题主要是要处理好进位的问题。代码实现publicint[]plusOne(int[]digi
yoshino
·
2020-04-06 15:28
LeetCode每日一题
:对称二叉树
问题描述Givenabinarytree,checkwhetheritisamirrorofitself(ie,symmetricarounditscenter).Forexample,thisbinarytreeissymmetric:1/22/\/3443Butthefollowingisnot:1/22\33Note:Bonuspointsifyoucouldsolveitbothrecur
yoshino
·
2020-04-06 15:05
LeetCode每日一题
:implement strstr
问题描述ImplementstrStr().Returnsapointertothefirstoccurrenceofneedleinhaystack,ornullifneedleisnotpartofhaystack.问题分析这道题考的是KMP算法,但是题目返回值却很诡异,我用indexof返回索引再改成String类型却总是过不了。代码实现publicStringstrStr(Stringha
yoshino
·
2020-04-06 11:21
LeetCode每日一题
:单独一个数 2
问题描述Givenanarrayofintegers,everyelementappearsthreetimesexceptforone.Findthatsingleone.Note:Youralgorithmshouldhavealinearruntimecomplexity.Couldyouimplementitwithoutusingextramemory?问题分析这道题和上一道基本一样,但
yoshino
·
2020-04-05 11:15
LeetCode每日一题
:通过有序数组建立二叉搜索树
问题描述Givenanarraywhereelementsaresortedinascendingorder,convertittoaheightbalancedBST.问题分析通过排序的数组建立二叉排序树,也是找中值的方式,其实intmid=(start+end)/2;就可以了,但是取模是为了保证能够AC。代码实现publicTreeNodesortedArrayToBST(int[]num){
yoshino
·
2020-04-04 23:03
LeetCode每日一题
:单独一个数 1
问题描述Givenanarrayofintegers,everyelementappearstwiceexceptforone.Findthatsingleone.Note:Youralgorithmshouldhavealinearruntimecomplexity.Couldyouimplementitwithoutusingextramemory?问题分析这道题说的是数组A中每个数都是出现两
yoshino
·
2020-04-04 07:07
LeetCode每日一题
:8. 字符串转换整数 (atoi)
写在前面:用c++写的时候报了越界的坑,后来稍作处理就很容易AC了欢迎访问我的力扣github仓库,有JavaScript和C++两个版本,每日更新C++代码:classSolution{public:intmyAtoi(stringstr){intmin=-pow(2,31),max=pow(2,31)-1;intflag=1,i=0;longlongsum=0;while(str[i]==''
慕尼黑、
·
2020-04-03 03:46
数据结构+算法
c++
字符串
正则表达式
js
JavaScript
LeetCode每日一题
:string to integer atoi
问题描述Implementatoitoconvertastringtoaninteger.Hint:Carefullyconsiderallpossibleinputcases.Ifyouwantachallenge,pleasedonotseebelowandaskyourselfwhatarethepossibleinputcases.Notes:Itisintendedforthisprob
yoshino
·
2020-04-03 01:52
LeetCode每日一题
:three sum
问题描述GivenanarraySofnintegers,arethereelementsa,b,cinSsuchthata+b+c=0?Findalluniquetripletsinthearraywhichgivesthesumofzero.Note:Elementsinatriplet(a,b,c)mustbeinnon-descendingorder.(ie,a≤b≤c)Thesoluti
yoshino
·
2020-04-02 00:22
上一页
27
28
29
30
31
32
33
34
下一页
按字母分类:
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
其他