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笔记
:371. Sum of Two Integers
问题:Calculatethesumoftwointegersaandb,butyouarenotallowedtousetheoperator+and-.Example:Givena=1andb=2,return3.大意:计算a和b两个整数的和,但是不能用+或-运算符。比如:给出a=1和b=2,返回3.思路:这道题乍看之下很简单,计算两个数之和嘛,但问题在于不能直接使用加号和减号,这就尴尬了,不
Cloudox_
·
2016-09-06 11:13
LeetCode
LeetCode笔记
LeetCode笔记
:371. Sum of Two Integers
问题:Calculatethesumoftwointegersaandb,butyouarenotallowedtousetheoperator+and-.Example:Givena=1andb=2,return3.大意:计算a和b两个整数的和,但是不能用+或-运算符。比如:给出a=1和b=2,返回3.思路:这道题乍看之下很简单,计算两个数之和嘛,但问题在于不能直接使用加号和减号,这就尴尬了,不
Cloudox_
·
2016-09-06 11:00
LeetCode
Leetcode笔记
(python)
326.PowerofThreeGivenaninteger,writeafunctiontodetermineifitisapowerofthree.(判断一个数是否是3的次方数,不使用循环和迭代)由于输入是int,正数范围是0-231,在此范围中允许的最大的3的次方数为319=1162261467,那么我们只要看这个数能否被n整除即可。classSolution(object):defisPo
跑者小越
·
2016-06-12 22:07
leetcode笔记
—Reorder List
给一个链表 L: L0→L1→…→Ln-1→Ln,需要返回: L0→Ln→L1→Ln-1→L2→Ln-2→…思路1:voidreorderList(ListNode*head){ ListNode*p=head; while(p&&p->next) { ListNode*pnext=p->next;//记下下一个节点 ListNode*temp=p; if(p->next->next==NULL)
sinat_27935693
·
2016-05-11 10:00
leetcode笔记
:Dungeon Game
一.题目描述Thedemonshadcapturedtheprincess(P)andimprisonedherinthebottom-rightcornerofadungeon.ThedungeonconsistsofMxNroomslaidoutina2Dgrid.Ourvaliantknight(K)wasinitiallypositionedinthetop-leftroomandmust
Herbert_Zero
·
2016-05-05 17:00
数据结构与算法
leetcode笔记
:Dungeon Game
一.题目描述Thedemonshadcapturedtheprincess(P)andimprisonedherinthebottom-rightcornerofadungeon.ThedungeonconsistsofMxNroomslaidoutina2Dgrid.Ourvaliantknight(K)wasinitiallypositionedinthetop-leftroomandmust
liyuefeilong
·
2016-05-05 17:00
LeetCode
Algorithm
C++
dp
动态规划
leetcode笔记
:Excel Sheet Column Number
一.题目描述GivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.Forexample:A->1 B->2 C->3 ... Z->26 AA->27 AB->28二.题目分析该题的题意是,给定一个出现在Excel表格中的列标题,返回其对应的列号。其实就是编写一个函数实现字符串到整数的转换。观察测试用例
liyuefeilong
·
2016-05-05 16:00
LeetCode
C++
算法
Excel
进制转换
leetcode笔记
—翻转链表
1、翻转链表voidreverseNodes(ListNode*start,ListNode*end){//翻转链表 ListNode*second=start->next; ListNode*first=start; ListNode*temp; while(second!=end){ temp=second->next; second->next=first; first=second;
sinat_27935693
·
2016-05-05 09:00
leetcode笔记
:Excel Sheet Column Number
一.题目描述GivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.Forexample:A->1 B->2 C->3 ... Z->26 AA->27 AB->28二.题目分析该题的题意是,给定一个出现在Excel表格中的列标题,返回其对应的列号。其实就是编写一个函数实现字符串到整数的转换。观察测试用例
Herbert_Zero
·
2016-05-05 00:00
leetcode
c++
excel
进制转换
算法
数据结构与算法
LeetCode笔记
:344. Reverse String
问题:Writeafunctionthattakesastringasinputandreturnsthestringreversed.Example:Givens=“hello”,return“olleh”.大意:写一个函数获取输入的字符串然后返回反转后后的字符串。比如:给出s=“hello”,返回”olleh”思路:思路很直接就想到,先把字符串拆分成一个个字符组成的数组,新建一个空字符串,然后
Cloudox_
·
2016-05-02 21:00
LeetCode
leetcode笔记
—Find the Duplicate Number
Givenanarray nums containing n +1integerswhereeachintegerisbetween1and n (inclusive),provethatatleastoneduplicatenumbermustexist.Assumethatthereisonlyoneduplicatenumber,findtheduplicateone.Note:You mu
sinat_27935693
·
2016-05-02 19:00
leetcode笔记
:Reverse Vowels of a String
一.题目描述Writeafunctionthattakesastringasinputandreverseonlythevowelsofastring.Example1:Givens="hello",return"holle".Example2:Givens="leetcode",return"leotcede".二.题目分析题目大意是,编写函数输入一个字符串,将其中的元音字母反转,其他字母位置不
liyuefeilong
·
2016-05-02 02:00
LeetCode
C++
算法
String
reverse
leetcode笔记
:Reverse String
一.题目描述Writeafunctionthattakesastringasinputandreturnsthestringreversed.Example:Givens="hello",return"olleh".二.题目分析题目大意是,编写一个函数,输入为一字符串,返回反序的字符串。如输入s=“hello”,返回”olleh”。这是一道水题,但是可以用很多种方法去解决,对于开阔思路很有帮助,也
liyuefeilong
·
2016-05-02 01:00
LeetCode
C++
算法
String
reverse
LeetCode笔记
:206. Reverse Linked List
题目:Reverseasinglylinkedlist.大意:反转一个简单链表。思路:题目的意思就是给出一个链表,本来是从头指向尾的,现在要你做成从尾指向头,并且返回原来的尾,现在的头。这个肯定是要用递归或者迭代来做。只要屡清楚过程,会比较绕。大体的流程就是,把下一个节点的next指向自己,一个个迭代、递归下去,最后返回最后的原来的尾节点他山之石:这里给出Discuss中最火的方法。迭代实现:pu
Cloudox_
·
2016-04-28 15:00
LeetCode
leetcode笔记
—二进制数中1的个数
基本思想:x=x&(x-1)可以消除x最右边的1;1.给出一个32位的二进制数,统计其中1的个数classSolution{ public: inthammingWeight(uint32_tn){//n=n&(n-1)可以消去最右边的1 intres=0; while(n) { n=n&(n-1); res++; } returnres; } };2.翻转一个32位数classSolution{
sinat_27935693
·
2016-04-26 21:00
leetcode笔记
:Merge Two Sorted Lists
一.题目描述Mergetwosortedlinkedlistsandreturnitasanewlist.Thenewlistshouldbemadebysplicingtogetherthenodesofthefirsttwolists.二.题目分析合并两个有序链表,递归或迭代均可以解决。三.示例代码/** *Definitionforsingly-linkedlist. *structList
liyuefeilong
·
2016-04-21 15:00
LeetCode
C++
算法
链表
归并
leetcode笔记
:Maximal Square
一.题目描述Givena2Dbinarymatrixfilledwith0’sand1’s,findthelargestsquarecontainingall1’sandreturnitsarea.Forexample,giventhefollowingmatrix:10100 10111 11111 10010Return4.二.题目分析题目大意是,给定一个二维矩阵(只包含字符'0'和'1'),
liyuefeilong
·
2016-04-20 23:00
LeetCode
C++
dp
动态规划
Matrix
leetcode笔记
:Remove Duplicate Letters
一.题目描述Givenastringwhichcontainsonlylowercaseletters,removeduplicateletterssothateveryletterappearonceandonlyonce.Youmustmakesureyourresultisthesmallestinlexicographicalorderamongallpossibleresults.Exa
liyuefeilong
·
2016-04-20 17:00
LeetCode
Algorithm
C++
算法
String
leetcode笔记
—判断查找二叉树
首先说明一下二叉树和二叉搜索树的区别。二叉树指这样的树结构,它的每个结点的孩子数目最多为2个;二叉搜索树是一种二叉树,但是它有附加的一些约束条件,这些约束条件必须对每个结点都成立:结点node的左子树所有结点的值都小于node的值。结点node的右子树所有结点的值都大于node的值。结点node的左右子树同样都必须是二叉搜索树。假定当前结点值为k。对于二叉树中每个结点,判断其左孩子的值是否小于k,
sinat_27935693
·
2016-04-20 09:00
leetcode笔记
:Integer Break
一.题目描述Givenapositiveintegern,breakitintothesumofatleasttwopositiveintegersandmaximizetheproductofthoseintegers.Returnthemaximumproductyoucanget.Forexample,givenn=2,return1(2=1+1);givenn=10,return36(10
liyuefeilong
·
2016-04-19 19:00
LeetCode
C++
算法
dp
动态规划
leetcode笔记
:Remove Linked List Elements
一.题目描述Removeallelementsfromalinkedlistofintegersthathavevalueval.ExampleGiven:1-->2-->6-->3-->4-->5-->6,val=6Return:1-->2-->3-->4-->5Credits:Specialthanksto@mithmattforaddingthisproblemandcreatingallt
liyuefeilong
·
2016-04-19 01:00
LeetCode
Algorithm
C++
算法
链表
leetcode笔记
:Implement Trie (Prefix Tree)
一.题目描述Implementatriewithinsert,search,andstartsWithmethods.Note:Youmayassumethatallinputsareconsistoflowercaselettersa-z.二.题目分析题目大意很简单,就是实现字典树,其中包括插入、查找和前缀查找三个方法。可以假设所有的输入只包含小写字母a-z。本题考查字典树数据结构的基础知识。需
liyuefeilong
·
2016-04-18 23:00
LeetCode
C++
trie
prefix
字典树
leetcode笔记
:Power of Four
一.题目描述Givenaninteger(signed32bits),writeafunctiontocheckwhetheritisapowerof4.Example:Givennum=16,returntrue.Givennum=5,returnfalse.Followup:Couldyousolveitwithoutloops/recursion?二.题目分析题目的大意是,给定一个32位有符
liyuefeilong
·
2016-04-18 19:00
LeetCode
位运算
C++
算法
power
LeetCode笔记
:169. Majority Element
题目:Givenanarrayofsizen,findthemajorityelement.Themajorityelementistheelementthatappearsmorethan⌊n/2⌋times.Youmayassumethatthearrayisnon-emptyandthemajorityelementalwaysexistinthearray.大意:给出一个尺寸为n的数组,找
Cloudox_
·
2016-04-16 15:00
LeetCode
LeetCode笔记
:169. Majority Element
题目:Givenanarrayofsizen,findthemajorityelement.Themajorityelementistheelementthatappearsmorethan⌊n/2⌋times.Youmayassumethatthearrayisnon-emptyandthemajorityelementalwaysexistinthearray.大意:给出一个尺寸为n的数组,找
Cloudox_
·
2016-04-16 15:00
LeetCode
LeetCode笔记
:217. Contains Duplicate
题目:Givenanarrayofintegers,findifthearraycontainsanyduplicates.Yourfunctionshouldreturntrueifanyvalueappearsatleasttwiceinthearray,anditshouldreturnfalseifeveryelementisdistinct.大意:给出一个int型的数组,判断数组是否包含
Cloudox_
·
2016-04-15 10:00
LeetCode
LeetCode笔记
:217. Contains Duplicate
题目:Givenanarrayofintegers,findifthearraycontainsanyduplicates.Yourfunctionshouldreturntrueifanyvalueappearsatleasttwiceinthearray,anditshouldreturnfalseifeveryelementisdistinct.大意:给出一个int型的数组,判断数组是否包含
Cloudox_
·
2016-04-15 10:00
LeetCode
LeetCode笔记
:171. Excel Sheet Column Number
题目:RelatedtoquestionExcelSheetColumnTitleGivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.Forexample:A->1B->2C->3…Z->26AA->27AB->28大意:与题目ExcelSheetColumnTitle相关给一个像Excel中显示的列
Cloudox_
·
2016-04-13 20:00
LeetCode
LeetCode笔记
:171. Excel Sheet Column Number
题目:RelatedtoquestionExcelSheetColumnTitleGivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.Forexample:A->1B->2C->3…Z->26AA->27AB->28大意:与题目ExcelSheetColumnTitle相关给一个像Excel中显示的列
Cloudox_
·
2016-04-13 20:00
LeetCode
leetcode笔记
-Path Sum
关于路径问题:1.输出所有的路径voidfindPath(vector>&ret,vectortmp,TreeNode*root) { if(root==NULL)return; tmp.push_back(root->val); if(root->left==NULL&&root->right==NULL) { ret.push_back(tmp); return; } if(root->lef
sinat_27935693
·
2016-04-12 20:00
Leetcode笔记
—最大路径和
public: intmaxPathSum(TreeNode*root){ intmaxsum=INT_MIN; dfs(root,maxsum); returnmaxsum; } intdfs(TreeNode*root,int&maxsum) { if(root==NULL)return0; intl=max(0,dfs(root->left,maxsum)); intr=max(0,dfs(
sinat_27935693
·
2016-04-12 17:00
leetcode笔记
:Reconstruct Itinerary
一.题目描述Givenalistofairlineticketsrepresentedbypairsofdepartureandarrivalairports[from,to],reconstructtheitineraryinorder.AlloftheticketsbelongtoamanwhodepartsfromJFK.Thus,theitinerarymustbeginwithJFK.N
liyuefeilong
·
2016-04-11 22:00
LeetCode
C++
算法
stack
DFS
leetcode笔记
-Kth Smallest Element in a BST
思路:定义一个中序遍历的函数,调用中序遍历将各个节点都存在VECTOR中,其中的数是从小到大的排列的,再取第K个最小的值/** *Definitionforabinarytreenode. *structTreeNode{ *intval; *TreeNode*left; *TreeNode*right; *TreeNode(intx):val(x),left(NULL),right(NULL){
sinat_27935693
·
2016-04-11 18:00
leetcode笔记
-层序遍历
/** *Definitionforabinarytreenode. *structTreeNode{ *intval; *TreeNode*left; *TreeNode*right; *TreeNode(intx):val(x),left(NULL),right(NULL){} *} */ classSolution{ public: vector>levelOrder(TreeNode*ro
sinat_27935693
·
2016-04-10 19:00
leetcode笔记
-zigzag层序遍历
zigzag层序遍历 /** *Definitionforabinarytreenode. *structTreeNode{ *intval; *TreeNode*left; *TreeNode*right; *TreeNode(intx):val(x),left(NULL),right(NULL){} *}; */ classSolution{ public: vector>zigzagLeve
sinat_27935693
·
2016-04-10 16:00
leetcode笔记
:Invert Binary Tree
一.题目描述Invertabinarytree.4 /\27 /\/\1369to4 /\72 /\/\9631Trivia:ThisproblemwasinspiredbythisoriginaltweetbyMaxHowell:Google:90%ofourengineersusethesoftwareyouwrote(Homebrew),butyoucan’tinvertabinarytre
liyuefeilong
·
2016-04-07 16:00
LeetCode
C++
算法
tree
二叉树
leetcode笔记
:Counting Bits
一.题目描述Givenanonnegativeintegernumbernum.Foreverynumbersiintherange0≤i≤numcalculatethenumberof1’sintheirbinaryrepresentationandreturnthemasanarray.Example:Fornum=5youshouldreturn[0,1,1,2,1,2].Followup:
liyuefeilong
·
2016-04-07 15:00
LeetCode
位运算
C++
算法
bits
数据结构与算法之leetcode刷题笔记
leetcode笔记
1、PowerofThreeJava版:https://leetcode.com/submissions/detail/51726417/2、RisingTemperatureJava
chongshangyunxiao321
·
2016-04-06 17:42
数据结构与算法
数据结构与算法之leetcode刷题笔记
leetcode笔记
1、PowerofThree Java版:https://leetcode.com/submissions/detail/51726417/ 2、RisingTemperatureJava
chongshangyunxiao321
·
2016-04-06 17:00
LeetCode笔记
:242. Valid Anagram
题目:Giventwostringssandt,writeafunctiontodetermineiftisananagramofs.Forexample,s=“anagram”,t=“nagaram”,returntrue.s=“rat”,t=“car”,returnfalse.Note:Youmayassumethestringcontainsonlylowercasealphabets.Fo
Cloudox_
·
2016-04-04 21:00
LeetCode
LeetCode笔记
:100. Same Tree
题目:Giventwobinarytrees,writeafunctiontocheckiftheyareequalornot.Twobinarytreesareconsideredequaliftheyarestructurallyidenticalandthenodeshavethesamevalue.大意:给出两个二叉树,写一个函数来检查两者是否相等。所谓相等,是指他们结构相同且节点有同样的
Cloudox_
·
2016-03-29 14:00
LeetCode
LeetCode笔记
:100. Same Tree
题目:Giventwobinarytrees,writeafunctiontocheckiftheyareequalornot.Twobinarytreesareconsideredequaliftheyarestructurallyidenticalandthenodeshavethesamevalue.大意:给出两个二叉树,写一个函数来检查两者是否相等。所谓相等,是指他们结构相同且节点有同样的
Cloudox_
·
2016-03-29 14:00
LeetCode
LeetCode笔记
:237. Delete Node in a Linked List
题目:Writeafunctiontodeleteanode(exceptthetail)inasinglylinkedlist,givenonlyaccesstothatnode.Supposedthelinkedlistis1->2->3->4andyouaregiventhethirdnodewithvalue3,thelinkedlistshouldbecome1->2->4afterca
Cloudox_
·
2016-03-28 19:00
LeetCode
LeetCode笔记
:237. Delete Node in a Linked List
题目:Writeafunctiontodeleteanode(exceptthetail)inasinglylinkedlist,givenonlyaccesstothatnode.Supposedthelinkedlistis1->2->3->4andyouaregiventhethirdnodewithvalue3,thelinkedlistshouldbecome1->2->4afterca
Cloudox_
·
2016-03-28 19:00
LeetCode
leetcode笔记
:Number of 1 Bits
一.题目描述Writeafunctionthattakesanunsignedintegerandreturnsthenumberof'1'bitsithas(alsoknownastheHammingweight).Forexample,the32-bitinteger'11'hasbinaryrepresentation00000000000000000000000000001011,soth
liyuefeilong
·
2016-03-28 18:00
LeetCode
位运算
C++
算法
LeetCode笔记
:283. Move Zeroes
题目:Givenanarraynums,writeafunctiontomoveall0’stotheendofitwhilemaintainingtherelativeorderofthenon-zeroelements.Forexample,givennums=[0,1,0,3,12],aftercallingyourfunction,numsshouldbe[1,3,12,0,0].Note
Cloudox_
·
2016-03-28 15:00
LeetCode
LeetCode笔记
:283. Move Zeroes
题目:Givenanarraynums,writeafunctiontomoveall0’stotheendofitwhilemaintainingtherelativeorderofthenon-zeroelements.Forexample,givennums=[0,1,0,3,12],aftercallingyourfunction,numsshouldbe[1,3,12,0,0].Note
Cloudox_
·
2016-03-28 15:00
LeetCode
LeetCode笔记
:226. Invert Binary Tree
问题:Invertabinarytree.toTrivia:Google:90%ofourengineersusethesoftwareyouwrote(Homebrew),>butyoucan’tinvertabinarytreeonawhiteboardsofuckoff.大意:反转一个二叉树。从到琐事:Google表示如果你连反转二叉树都做不到就滚吧。思路:对于二叉树的每个子节点的左右节点都
Cloudox_
·
2016-03-26 15:00
LeetCode
反转二叉树
LeetCode笔记
:226. Invert Binary Tree
问题:Invertabinarytree.toTrivia:Google:90%ofourengineersusethesoftwareyouwrote(Homebrew),>butyoucan’tinvertabinarytreeonawhiteboardsofuckoff.大意:反转一个二叉树。从到琐事:Google表示如果你连反转二叉树都做不到就滚吧。思路:对于二叉树的每个子节点的左右节点都
Cloudox_
·
2016-03-26 15:00
LeetCode
反转二叉树
LeetCode笔记
:104.Maximum Depth of Binary Tree
问题:Givenabinarytree,finditsmaximumdepth.Themaximumdepthisthenumberofnodesalongthelongestpathfromtherootnodedowntothefarthestleafnode.大意:给出一个二叉树,找到其最大的深度。最大深度是指从根节点到最远的叶子节点的最长距离的节点数。思路:要探索二叉树的深度,用递归比较方
Cloudox_
·
2016-03-26 14:00
LeetCode
二叉树
上一页
9
10
11
12
13
14
15
16
下一页
按字母分类:
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
其他