LeetCode解题报告汇总! All in One!

作者: 负雪明烛
id: fuxuemingzhu
个人博客: http://fuxuemingzhu.cn/


把自己刷过的所有题目做一个整理,并且用简洁的语言概括了一下思路,汇总成了一个表格。

题目的排列顺序是按照先Easy再Medium再Hard排列的,暂时还没有把题目全部整理完成。后序我会把刷过的所有的题目都整理到这个文档里。

题目难度解法题目地址
566. Reshape the MatrixEasy变长数组,求余法,维护行列计算在新的数组中的位置https://blog.csdn.net/fuxuemingzhu/article/details/83626519
567. Increasing Order Search TreeEasy直接中序遍历的结果放到链表结尾https://blog.csdn.net/fuxuemingzhu/article/details/82349263
568. Jewels and StonesEasy字典统计次数https://blog.csdn.net/fuxuemingzhu/article/details/79188903
569. Unique Email AddressesEasy字符串+set统计个数https://blog.csdn.net/fuxuemingzhu/article/details/83478570
570. To Lower CaseEasyASIIC码操作ord,chrhttps://blog.csdn.net/fuxuemingzhu/article/details/81015228
571. Unique Morse Code WordsEasy字典映射 + set统计个数https://blog.csdn.net/fuxuemingzhu/article/details/79774003
572. Sort Array By ParityEasy自定义sorted函数的cmp为数字mod 2https://blog.csdn.net/fuxuemingzhu/article/details/82732066
573. Hamming DistanceEasy先异或 再数1的个数https://blog.csdn.net/fuxuemingzhu/article/details/54138423
574. Robot Return to OriginEasyCounter统计,判断是否相等https://blog.csdn.net/fuxuemingzhu/article/details/83663650
575. Flipping an ImageEasy直接计算新的数组的每个位置的值即可https://blog.csdn.net/fuxuemingzhu/article/details/80471495
576. Merge Two Binary TreesEasy树的递归操作https://blog.csdn.net/fuxuemingzhu/article/details/79052953
577. Implement strStr()Easy字符串遍历+切片是否相等的判断https://blog.csdn.net/fuxuemingzhu/article/details/79254558
578. Find and Replace PatternEasy直接使用字典做映射https://blog.csdn.net/fuxuemingzhu/article/details/82014687
579. Binary Tree PruningMedium二叉树的后序遍历https://blog.csdn.net/fuxuemingzhu/article/details/79858752
580. Array Partition IEasy排序+求和https://blog.csdn.net/fuxuemingzhu/article/details/71412574
581. Self Dividing NumbersEasy直接遍历区间的每个数字进行判断https://blog.csdn.net/fuxuemingzhu/article/details/79053113
582. Peak Index in a Mountain ArrayEasy二分查找的变种,使用Mid位置和左右位置比较https://blog.csdn.net/fuxuemingzhu/article/details/80721162
583. Sort Array By Parity IIEasy分别求出奇偶数组然后拼接https://blog.csdn.net/fuxuemingzhu/article/details/83045735
584. Projection Area of 3D ShapesEasy分别计算三视图的面积即可https://blog.csdn.net/fuxuemingzhu/article/details/81748335
585. Smallest Range IEasy直接数学计算https://blog.csdn.net/fuxuemingzhu/article/details/82824685
586. Transpose MatrixEasy先构建数组再遍历实现翻转https://blog.csdn.net/fuxuemingzhu/article/details/81015450
587. N-ary Tree Preorder TraversalEasy多叉树的先序遍历,可以用递归和迭代https://blog.csdn.net/fuxuemingzhu/article/details/81021950
588. N-ary Tree Postorder TraversalEasy多叉树的后序遍历https://blog.csdn.net/fuxuemingzhu/article/details/81017965
589. Intersection of Two Arrays IIEasy先排序然后用两个指针移动找出数组交集https://blog.csdn.net/fuxuemingzhu/article/details/54341965
590. Middle of the Linked ListEasy快慢指针同时向链表后面移动https://blog.csdn.net/fuxuemingzhu/article/details/81748484
591. Search in a Binary Search TreeEasyBST中节点的查找,递归https://blog.csdn.net/fuxuemingzhu/article/details/81015754
592. Number of Recent CallsEasy找出满足一定条件的区间长度,可以使用二分或者队列https://blog.csdn.net/fuxuemingzhu/article/details/83714891
593. Maximum Depth of N-ary TreeEasy求树的高度,可以使用BFS和DFShttps://blog.csdn.net/fuxuemingzhu/article/details/81021864
594. Reverse Words in a String IIIEasy字符串的单词分别翻转再拼接到一起就好了https://blog.csdn.net/fuxuemingzhu/article/details/70141268
595. Number of Lines To Write StringEasy使用字典保存每个字符的长度,然后统计每行的长度是否超过100就好了https://blog.csdn.net/fuxuemingzhu/article/details/79810381
596. Reverse StringEasy字符串翻转,[::-1https://blog.csdn.net/fuxuemingzhu/article/details/51284382
597. Subdomain Visit CountEasy字典保存每个子域名出现的次数即可https://blog.csdn.net/fuxuemingzhu/article/details/79789925
598. Number ComplementEasy求数字的补数,方法是异或上与其二进制数字的长度相等的全1二进制数https://blog.csdn.net/fuxuemingzhu/article/details/54562124
599. Shortest Distance to a CharacterEasy过两遍数组,分别找出距离左边和右边的这个字符的最短距离https://blog.csdn.net/fuxuemingzhu/article/details/80471765
600. Keyboard RowEasy使用字典保存每行元素,然后看每个单词是不是只由一行元素组成https://blog.csdn.net/fuxuemingzhu/article/details/68953517
601. Groups of Special-Equivalent StringsEasy把奇偶位置都取出来,重新拼接成字符串作为指纹,看总的有多少种指纹https://blog.csdn.net/fuxuemingzhu/article/details/82083609
602. Leaf-Similar TreesEasy先序、中序、后序都能得到叶子序列https://blog.csdn.net/fuxuemingzhu/article/details/81748617
603. Uncommon Words from Two SentencesEasy使用字典统计每个单词出现的次数,然后看字典keys()的交集,然后在字典中看是不是只出现了一次https://blog.csdn.net/fuxuemingzhu/article/details/81749170
604. Toeplitz MatrixEasy判断每个斜线是否相等,方法是判断每个元素是否和其左上角元素相等https://blog.csdn.net/fuxuemingzhu/article/details/79127213
605. Island PerimeterEasy求小岛的周长。使用所有陆地个数×4-相交部分×2.https://blog.csdn.net/fuxuemingzhu/article/details/83868905
606. Baseball GameEasy用一个栈进行模拟https://blog.csdn.net/fuxuemingzhu/article/details/79183412
607. Binary GapEasy二进制表示中1的最大间距,保留上一个1的位置即可https://blog.csdn.net/fuxuemingzhu/article/details/81079495
608. Maximum Depth of Binary TreeEasy二叉树的高度,可以用DFS和BFShttps://blog.csdn.net/fuxuemingzhu/article/details/48490829
609. Single NumberEasy所有的数字出现了两次,其中一个只出现了一次。找出这个数字的方法可以使用字典统计或者异或运算https://blog.csdn.net/fuxuemingzhu/article/details/54173334
610. Next Greater Element IEasy找出某个数字右边比他大的数字,直接遍历查找就好了https://blog.csdn.net/fuxuemingzhu/article/details/79080337
611. Average of Levels in Binary TreeEasy求每层的二叉树的均值,可以使用BFS和DFShttps://blog.csdn.net/fuxuemingzhu/article/details/79088554
612. Binary Number with Alternating BitsEasy判断数字的二进制表示是不是01交错的。直接遍历判断,或者位运算。https://blog.csdn.net/fuxuemingzhu/article/details/79089937
613. Prime Number of Set Bits in Binary RepresentationEasy判断二进制数字的1的个数是不是质数https://blog.csdn.net/fuxuemingzhu/article/details/79089092
614. Reverse Only LettersEasy只翻转字母其余字符不动,可以使用栈、双指针https://blog.csdn.net/fuxuemingzhu/article/details/82956271
615. Nim GameEasy判断输入数字是不是4的倍数即可https://blog.csdn.net/fuxuemingzhu/article/details/51284421
616. Goat LatinEasy字符串处理,简单https://blog.csdn.net/fuxuemingzhu/article/details/80471925
617. Surface Area of 3D ShapesEasy统计立方体个数,减去相交面积https://blog.csdn.net/fuxuemingzhu/article/details/82083893
618. Letter Case PermutationEasy经典回溯法,把字符的大小写分别拼接到字符串尾部https://blog.csdn.net/fuxuemingzhu/article/details/79360330
619. Add DigitsEasy两重循环,一直对每位数字求和直到剩余个位数https://blog.csdn.net/fuxuemingzhu/article/details/49161129
620. Move ZeroesEasy使用一个指针指向第一个为0的位置,然后遍历不是0的位置进行交换https://blog.csdn.net/fuxuemingzhu/article/details/51284981
621. Shortest Completing WordEasy找出符合某个模式的字符串,直接处理就好了https://blog.csdn.net/fuxuemingzhu/article/details/79432228
622. Employee ImportanceEasydfshttps://blog.csdn.net/fuxuemingzhu/article/details/79091343
623. Find the DifferenceEasy找多出来的字符,可以使用字典,也可以使用异或https://blog.csdn.net/fuxuemingzhu/article/details/54174443
624. Detect CapitalEasy统计大写字符的个数,判断是不是在首位https://blog.csdn.net/fuxuemingzhu/article/details/68957658
625. Find All Numbers Disappeared in an ArrayEasy用set去重,找出没有出现的数字即可https://blog.csdn.net/fuxuemingzhu/article/details/53981307
626. Count Binary SubstringsEasy先找出连续的0,1个数,然后进行交错求最小值,在求和https://blog.csdn.net/fuxuemingzhu/article/details/79183556
627. 4Sum IIEasy4sum,先确定两个数字,然后看剩余两个数字的和是否出现过https://blog.csdn.net/fuxuemingzhu/article/details/79473739
628. Rotated DigitsEasy字典保存翻转后的数字,判断是否相等即可。https://blog.csdn.net/fuxuemingzhu/article/details/79378135
629. Two Sum IV - Input is a BSTEasyBFS或者DFS,在遍历的过程中进行破案吨https://blog.csdn.net/fuxuemingzhu/article/details/79120732
630. Sum of Two IntegersEasy位运算https://blog.csdn.net/fuxuemingzhu/article/details/79379939
631. Intersection of Two ArraysEasy用两个set求交集,然后转成List即可https://blog.csdn.net/fuxuemingzhu/article/details/54236183
632. Construct String from Binary TreeEasy先序遍历,可以省略右子树,所以需要做一个节点是否存在的判断https://blog.csdn.net/fuxuemingzhu/article/details/79121550
633. Reverse Linked ListEasy翻转单链表,可以使用递归和迭代https://blog.csdn.net/fuxuemingzhu/article/details/51290121
634. Majority ElementEasyMoore投票法,或者字典统计次数https://blog.csdn.net/fuxuemingzhu/article/details/51288749
635. Excel Sheet Column NumberEasy26进制,没有难度https://blog.csdn.net/fuxuemingzhu/article/details/51286467
636. Roman to IntegerEasy使用字典保存映射,遍历求值就好了。https://blog.csdn.net/fuxuemingzhu/article/details/48208995
637. Reorder Log FilesEasy分割排序,再拼接https://blog.csdn.net/fuxuemingzhu/article/details/83961188
638. Best Time to Buy and Sell StockEasy一次遍历,如果后一天比前一天大就买了卖https://blog.csdn.net/fuxuemingzhu/article/details/51291151
639. Valid AnagramEasy判断字符串是否是同构的,直接统计词频或者排序https://blog.csdn.net/fuxuemingzhu/article/details/51286195
640. Lemonade ChangeEasy贪心算法,找零钱先找大的面额,如果不够再用小的面额https://blog.csdn.net/fuxuemingzhu/article/details/80913955
641. Contains DuplicateEasy判断数组是否有重复,可以统计词频,判断set长度是否相等,排序等方法https://blog.csdn.net/fuxuemingzhu/article/details/51289768
642. Construct Quad TreeEasy建立四叉树,使用递归,判断4个叶子全部是0或者1https://blog.csdn.net/fuxuemingzhu/article/details/81836838
643. Design HashMapEasy设计一个字典,直接开个很大的数组即可,内存放得下https://blog.csdn.net/fuxuemingzhu/article/details/81017297
644. Convert BST to Greater TreeEasy把每个节点变成比它大的节点的值的和,采用逆中序遍历。https://blog.csdn.net/fuxuemingzhu/article/details/79132336
645. Same TreeEasy判断两棵数是否相等,直接递归https://blog.csdn.net/fuxuemingzhu/article/details/51285076
646. Minimum Absolute Difference in BSTEasy中序遍历,保存前一个节点,当前节点的值减去前一个节点的值https://blog.csdn.net/fuxuemingzhu/article/details/69666671
647. Minimum Distance Between BST NodesEasy和上题完全一样https://blog.csdn.net/fuxuemingzhu/article/details/79402127
648. Ransom NoteEasy使用字典统计每个字符出现的次数,前者小于后者即可https://blog.csdn.net/fuxuemingzhu/article/details/54178342
649. Rotate StringEasy字符串切片https://blog.csdn.net/fuxuemingzhu/article/details/79521194
650. 1-bit and 2-bit CharactersEasy单次遍历,判断前面满足的条件下,最后一位是0即可。https://blog.csdn.net/fuxuemingzhu/article/details/79130681
651. Minimum Moves to Equal Array ElementsEasy把n-1个数字加1,相等于把最大值-1.求和-n*最小值https://blog.csdn.net/fuxuemingzhu/article/details/54177981
652. Flood FillEasy对相同颜色进行染色,可以使用DFS和BFS.https://blog.csdn.net/fuxuemingzhu/article/details/79401716
653. Sum of Left LeavesEasy求所有左叶子的和,要判断是不是在左边,判断是不是叶子,然后加到结果中https://blog.csdn.net/fuxuemingzhu/article/details/54178595
654. Number of BoomerangsEasy统计回旋镖的个数,不能暴力解决,需要使用排列组合公式n*(n-1)https://blog.csdn.net/fuxuemingzhu/article/details/54379349
655. Range Addition IIEasy求队列的最小值即可https://blog.csdn.net/fuxuemingzhu/article/details/79398272
656. Construct the RectangleEasy从算术平方根开始找约数即可https://blog.csdn.net/fuxuemingzhu/article/details/68957959
657. Two Sum II - Input array is sortedEasy前后指针同时向中间走,找到target之后停止https://blog.csdn.net/fuxuemingzhu/article/details/70232518
658. First Unique Character in a StringEasy首先做个字符出现次数的统计,然后再次遍历,找出只出现了一次的第一个字符。https://blog.csdn.net/fuxuemingzhu/article/details/84139374
659. Degree of an ArrayEasy求最大的出现次数的所有数字,其最左右出现的位置差的最小值https://blog.csdn.net/fuxuemingzhu/article/details/79146067
660. Assign CookiesEasy贪心算法,尽可能给小孩满足其欲望的饼干https://blog.csdn.net/fuxuemingzhu/article/details/54177627
661. Convert Sorted Array to Binary Search TreeEasy构建BST,使用中间数进行分割,用递归https://blog.csdn.net/fuxuemingzhu/article/details/70665213
662. Relative RanksEasy相对排名,可以使用堆或者排序或者argsorthttps://blog.csdn.net/fuxuemingzhu/article/details/70173434
663. Image SmootherEasy直接暴力求平均即可https://blog.csdn.net/fuxuemingzhu/article/details/79156499
664. Longest PalindromeEasy统计出现次数的奇偶就可以https://blog.csdn.net/fuxuemingzhu/article/details/54236594
665. Minimum Index Sum of Two ListsEasy保存出现的索引和与元素的对应,使用堆保存最小的就行https://blog.csdn.net/fuxuemingzhu/article/details/79138621
666. Missing NumberEasy理论和-当前和https://blog.csdn.net/fuxuemingzhu/article/details/70332471
667. Binary Tree TiltEasy后序遍历函数返回的是左右子树的差,在里面用变量求和https://blog.csdn.net/fuxuemingzhu/article/details/71440281
668. Positions of Large GroupsEasy找到长度大于3的连续字符,需要判断结束!!https://blog.csdn.net/fuxuemingzhu/article/details/80472242
669. Intersection of Two Arrays IIEasy可以排序,也可以使用字典统计次数https://blog.csdn.net/fuxuemingzhu/article/details/54341965
670. Diameter of Binary TreeEasy递归求树的深度,同时求左右两个深度的和的最大值https://blog.csdn.net/fuxuemingzhu/article/details/70338312
671. Student Attendance Record IEasy统计A的个数,并且判断连续L的个数https://blog.csdn.net/fuxuemingzhu/article/details/70337973
672. Best Time to Buy and Sell StockEasy保存当前的最小值以及最大收益即可https://blog.csdn.net/fuxuemingzhu/article/details/51291151
673. Maximum Product of Three NumbersEasy找出三个数最大的乘积https://blog.csdn.net/fuxuemingzhu/article/details/79169635
674. Binary WatchEasy使用combinations函数https://blog.csdn.net/fuxuemingzhu/article/details/54344098
675. Min Cost Climbing StairsEasy动态规划https://blog.csdn.net/fuxuemingzhu/article/details/79188612
676. Long Pressed NameEasy使用双指针,统计连续字符出现的次数https://blog.csdn.net/fuxuemingzhu/article/details/83245395
677. Reverse String IIEasyPython的切片翻转https://blog.csdn.net/fuxuemingzhu/article/details/70141909
678. Design HashSetEasy直接开数组就行https://blog.csdn.net/fuxuemingzhu/article/details/81016992
679. Binary Tree Level Order Traversal IIEasyDFS和BFS都可以https://blog.csdn.net/fuxuemingzhu/article/details/49108449
680. Base 7Easy转成7进制https://blog.csdn.net/fuxuemingzhu/article/details/70194688
681. Distinct SubsequencesEasy动规,判断当前字符是否相等https://blog.csdn.net/fuxuemingzhu/article/details/84228383
682. Merge Two Sorted ListsEasy可以使用递归或者迭代https://blog.csdn.net/fuxuemingzhu/article/details/51291406
683. Poor PigsEasy类似拨号键盘,多维空间求解https://blog.csdn.net/fuxuemingzhu/article/details/81079261
684. Binary Tree PathsEasy打印二叉树的路径,使用递归和迭代https://blog.csdn.net/fuxuemingzhu/article/details/71249429
685. Backspace String CompareEasy字符串可以退格,使用栈轻松解决https://blog.csdn.net/fuxuemingzhu/article/details/80643408
686. Happy NumberEasy递归和迭代两种做法https://blog.csdn.net/fuxuemingzhu/article/details/49180507
687. Longest Continuous Increasing SubsequenceEasy简单的动态规划https://blog.csdn.net/fuxuemingzhu/article/details/79220527
688. Find Smallest Letter Greater Than TargetEasy线性扫描或者二分https://blog.csdn.net/fuxuemingzhu/article/details/79137225
689. Pascal’s TriangleEasy提前构造出来,然后处理每行即可https://blog.csdn.net/fuxuemingzhu/article/details/51346488
690. Second Minimum Node In a Binary TreeEasy递归的时候找第二小值https://blog.csdn.net/fuxuemingzhu/article/details/79222455
691. Longest Word in DictionaryEasy先排序,再找前缀是否存在。https://blog.csdn.net/fuxuemingzhu/article/details/79123277
692. Remove ElementEasy使用双指针或者标记指针使得前面都是满足要求的,后面都不满足https://blog.csdn.net/fuxuemingzhu/article/details/51303161
693. Climbing StairsEasy动态规划https://blog.csdn.net/fuxuemingzhu/article/details/51290778
694. Add StringsEasy直接模拟大整数加法,需要注意进位问题https://blog.csdn.net/fuxuemingzhu/article/details/54380737
695. Lowest Common Ancestor of a Binary Search TreeEasyBST找公共祖先,使用递归很简单https://blog.csdn.net/fuxuemingzhu/article/details/51290289
696. Longest Harmonious SubsequenceEasy统计相邻的数字是否都存在即可https://blog.csdn.net/fuxuemingzhu/article/details/79233752
697. Symmetric TreeEasy可以使用BFS和DFS两种方法https://blog.csdn.net/fuxuemingzhu/article/details/51345707
698. Maximum SubarrayEasy动态规划找子数组最大和https://blog.csdn.net/fuxuemingzhu/article/details/71101802
699. Most Common WordEasy正则+统计https://blog.csdn.net/fuxuemingzhu/article/details/80472079
700. Power of TwoEasy判断二进制是不是只有1个1即可https://blog.csdn.net/fuxuemingzhu/article/details/51290981
701. Convert a Number to HexadecimalEasy转成16进制,难点在于负数的处理:加上1<<32https://blog.csdn.net/fuxuemingzhu/article/details/54426643
702. Remove Duplicates from Sorted ListEasy递归和循环https://blog.csdn.net/fuxuemingzhu/article/details/51290506
703. Power of ThreeEasy循环和迭代https://blog.csdn.net/fuxuemingzhu/article/details/51290895
704. Number of 1 BitsEasy使用位移统计二进制个数https://blog.csdn.net/fuxuemingzhu/article/details/51290376
705. Path Sum IIIEasy找路径的个数,使用DFS*2或者BFS+DFShttps://blog.csdn.net/fuxuemingzhu/article/details/71097135
706. Binary SearchEasy二分的模板https://blog.csdn.net/fuxuemingzhu/article/details/81017415
707. Pascal’s Triangle IIEasy原地翻转可以用倒序遍历https://blog.csdn.net/fuxuemingzhu/article/details/51348629
708. Implement Queue using StacksEasy两个栈实现一个队列https://blog.csdn.net/fuxuemingzhu/article/details/51345762
709. Subtree of Another TreeEasyDFS*2或DFS+BSFhttps://blog.csdn.net/fuxuemingzhu/article/details/71440802
710. House RobberEasy简单dp,当前房间偷和不偷两种状态https://blog.csdn.net/fuxuemingzhu/article/details/51291936
711. Kth Largest Element in a StreamEasy使用小根堆维护k个值,则第一个元素就是第k大元素https://blog.csdn.net/fuxuemingzhu/article/details/81027116
712. Reverse Vowels of a StringEasy使用栈进行翻转,或者使用双指针https://blog.csdn.net/fuxuemingzhu/article/details/51291677
713. Plus OneEasy使用carry表示进位https://blog.csdn.net/fuxuemingzhu/article/details/51346096
714. Ugly NumberEasy除去2,3,5因子即可https://blog.csdn.net/fuxuemingzhu/article/details/49183961
715. Search Insert PositionEasy二分查找https://blog.csdn.net/fuxuemingzhu/article/details/70738108
716. Set MismatchEasy使用统计次数或者直接求和计算https://blog.csdn.net/fuxuemingzhu/article/details/79247916
717. Largest Number At Least Twice of OthersEasy找出最大值,然后弹掉,再找次大值即可。https://blog.csdn.net/fuxuemingzhu/article/details/79188909
718. Power of FourEasy递归和迭代https://blog.csdn.net/fuxuemingzhu/article/details/51291091
719. Find Pivot IndexEasy先求和,在遍历求前半部分的和,找出左边等于右边https://blog.csdn.net/fuxuemingzhu/article/details/79248308
720. Palindrome NumberEasy可以先翻转成整数,然后判断和原来的是否相等https://blog.csdn.net/fuxuemingzhu/article/details/71334663
721. License Key FormattingEasy计算第一个分割的长度,后面都是等长的了https://blog.csdn.net/fuxuemingzhu/article/details/79234075
722. Two SumEasy保存已经出现过的数字的索引,当下次遍历的时候遇到了满足要求的结果,那么既是停止https://blog.csdn.net/fuxuemingzhu/article/details/72465759
723. Repeated Substring PatternEasy判断每个子串重复多次能不能组成原来的串即可https://blog.csdn.net/fuxuemingzhu/article/details/54564801
724. Maximize Distance to Closest PersonEasy从前向后以及从后向前遍历两次,取最近距离https://blog.csdn.net/fuxuemingzhu/article/details/80643250
725. Count and SayEasy统计字符连续出现的次数,并说出来,需要注意最后的一个字符也要添加上去https://blog.csdn.net/fuxuemingzhu/article/details/71618640
726. Remove Duplicates from Sorted Array IIEasy快指针移动判断和慢指针是否相等,如果不等就换到前面来https://blog.csdn.net/fuxuemingzhu/article/details/82829709
727. Maximum Average Subarray IEasy一定注意是长度为k的滑动窗口,注意下标https://blog.csdn.net/fuxuemingzhu/article/details/79248629
728. Find Mode in Binary Search TreeEasy如果使用附加空间,可以使用字典保存次数;否则需要遍历两次,判断出现次数。https://blog.csdn.net/fuxuemingzhu/article/details/71124600
729. Guess Number Higher or LowerEasy使用二分查找https://blog.csdn.net/fuxuemingzhu/article/details/71516105
730. Network Delay TimeEasydijkstra算法https://leetcode.com/problems/network-delay-time/description/
731. Quad Tree IntersectionEasy递归构造https://blog.csdn.net/fuxuemingzhu/article/details/82356008
732. Factorial Trailing ZeroesEasy数有多少个5就行了https://blog.csdn.net/fuxuemingzhu/article/details/51347044
733. Arranging CoinsEasy二分查找满足条件的层数即可https://blog.csdn.net/fuxuemingzhu/article/details/71330733
734. Implement Stack using QueuesEasy使用一个队列就能实现栈,每次Push的时候,把队列里的所有元素弹出再放进来就好了。https://blog.csdn.net/fuxuemingzhu/article/details/72598111
735. Add BinaryEasy使用进位进行模拟ddhttps://blog.csdn.net/fuxuemingzhu/article/details/77341154v
736. Number of Segments in a StringEasystring.split()默认就是按照多个空格分割https://blog.csdn.net/fuxuemingzhu/article/details/71194298
737. Path SumEasy递归和迭代都能满足https://blog.csdn.net/fuxuemingzhu/article/details/71715810
738. Isomorphic StringsEasy分别看s到t的映射和t到s的映射是不是一一映射的https://blog.csdn.net/fuxuemingzhu/article/details/72127108
739. String CompressionEasy使用Pos变量维护应该放到哪个位置,然后一次遍历统计次数就好了https://blog.csdn.net/fuxuemingzhu/article/details/79183289
740. Range Sum Query - ImmutableEasy保存每个位置的累积和https://blog.csdn.net/fuxuemingzhu/article/details/79253036
741. Find All Anagrams in a StringEasy滑动窗口,保存等长的子字符串中包含的字符数是否和另外一个相等https://blog.csdn.net/fuxuemingzhu/article/details/79184109
742. Valid ParenthesesEasy使用栈判断括号是否合法https://blog.csdn.net/fuxuemingzhu/article/details/72366868
743. Magic Squares In GridEasy暴力判断每个9*9的格子是不是满足题意的河图https://blog.csdn.net/fuxuemingzhu/article/details/80473253
744. Linked List CycleEasy走两步走一步,看是否重合https://blog.csdn.net/fuxuemingzhu/article/details/51297249
745. Remove Linked List ElementsEasy递归解法不好想,但是代码很简单https://blog.csdn.net/fuxuemingzhu/article/details/77340945
746. Palindrome Linked ListEasy利用一个数组保存所有的数字,然后判断数组是不是回文的。https://blog.csdn.net/fuxuemingzhu/article/details/72597942
747. Minimum Depth of Binary TreeEasyDFS/BFS,其实DFS更难https://blog.csdn.net/fuxuemingzhu/article/details/48519035
748. Word PatternEasy一一映射https://blog.csdn.net/fuxuemingzhu/article/details/72528424
749. Min StackEasy使用辅助栈保存最小值https://blog.csdn.net/fuxuemingzhu/article/details/79253237
750. Contains Duplicate IIEasy使用字典保存出现的位置,当新的元素到来的时候,更新字典https://blog.csdn.net/fuxuemingzhu/article/details/77387169
751. Valid Mountain ArrayEasy两个while就可以了https://blog.csdn.net/fuxuemingzhu/article/details/84206380
752. Merge Sorted ArrayEasy从后向前进行遍历,每次找到大的往后移动https://blog.csdn.net/fuxuemingzhu/article/details/77444695
753. X of a Kind in a Deck of CardsEasy需要进行一个遍历,找到是否存在这个分组大小https://blog.csdn.net/fuxuemingzhu/article/details/82914279
754. Valid Palindrome IIEasy需要用到双指针,先找到第一个不相等的位置,然后去除左边或者右边,判断是否是回文https://blog.csdn.net/fuxuemingzhu/article/details/79252779
755. Longest Univalue PathEasy定义的DFS是对过root的单臂进行循环,但是更新的结果是双臂,有点意思https://blog.csdn.net/fuxuemingzhu/article/details/79248926
756. Longest Common PrefixEasy遍历最短的子串的每一位,看所有字符串在这一位上是不是相等的https://blog.csdn.net/fuxuemingzhu/article/details/77561186
757. Repeated String MatchEasy重复NB/NA + 3次,看b是不是在a里https://blog.csdn.net/fuxuemingzhu/article/details/79574835
122.Best Time to Buy and Sell Stock IIEasy只要每天的比前面一天高,那么就买上并且卖掉即可https://blog.csdn.net/fuxuemingzhu/article/details/70258549
758. Implement strStr()Easy循环加切片https://blog.csdn.net/fuxuemingzhu/article/details/79254558
759. HeatersEasy找出最临近的距离https://blog.csdn.net/fuxuemingzhu/article/details/79254295
760. Reach a NumberEasy数学题,非常不喜欢https://blog.csdn.net/fuxuemingzhu/article/details/84556932
761. Nth DigitEasy数学计算第多少位https://blog.csdn.net/fuxuemingzhu/article/details/84559975
762. Sqrt(x)Easy二分查找或者牛顿法https://blog.csdn.net/fuxuemingzhu/article/details/79254648
763. Shortest Unsorted Continuous SubarrayEasy先排序,然后比较不等的位置https://blog.csdn.net/fuxuemingzhu/article/details/79254454
764. Reverse BitsEasy翻转二进制再转成整数https://blog.csdn.net/fuxuemingzhu/article/details/79254344
765. Valid PalindromeEasy过滤掉不是字母的字符,然后判断是不是回文即可https://blog.csdn.net/fuxuemingzhu/article/details/79252936
766. Walking Robot SimulationEasy模拟整个过程即可https://blog.csdn.net/fuxuemingzhu/article/details/82356556
767. K-diff Pairs in an ArrayEasy找绝对值出现等于k的次数,需要对k进行判断https://blog.csdn.net/fuxuemingzhu/article/details/79255633
768. Excel Sheet Column TitleEasy需要对26取余,并且做个判断,因为0\26对26取余的结果是一样的https://blog.csdn.net/fuxuemingzhu/article/details/51286857
769. Rotate ArrayEasy可以使用额外数组,也可使用递归原地翻转https://blog.csdn.net/fuxuemingzhu/article/details/79258753
770. Non-decreasing ArrayEasy找到变小的位置,然后和再前面的数字进行判断,看是应该修改当前的还是前面的https://blog.csdn.net/fuxuemingzhu/article/details/79264475
771. Design Linked ListEasy自己实现链表,挺复杂的。可以使用list进行模拟,方便很多。https://blog.csdn.net/fuxuemingzhu/article/details/81026066
772. Range Sum of BSTMedium需要根据根节点的值进行判断,邮编和左边需不需要继续寻找https://blog.csdn.net/fuxuemingzhu/article/details/83961263
773. Max Increase to Keep City SkylineMedium分别找出行和咧的最大值,把每个位置增长到行列最大值的最小值https://blog.csdn.net/fuxuemingzhu/article/details/79820383
774. Encode and Decode TinyURLMedium使用字典完成映射https://blog.csdn.net/fuxuemingzhu
775. Maximum Binary TreeMedium找到最大值,然后数组切片https://blog.csdn.net/fuxuemingzhu/article/details/79265180
776. Insert into a Binary Search TreeMedium递归解法,直接对当前节点进行操作!https://blog.csdn.net/fuxuemingzhu/article/details/82385503
777. Find and Replace PatternMedium判断是不是一一映射https://blog.csdn.net/fuxuemingzhu/article/details/82014687
778. Minimum Add to Make Parentheses ValidMedium使用一个栈https://blog.csdn.net/fuxuemingzhu/article/details/83045871
779. All Paths From Source to TargetMedium回溯法找路径https://blog.csdn.net/fuxuemingzhu/article/details/79624149
780. Score After Flipping MatrixMedium把行进行翻转,按列统计1的个数即可https://blog.csdn.net/fuxuemingzhu/article/details/81118328
781. All Possible Full Binary TreesMedium使用两种循环遍历可能构成的左子树和右子树,每次构建新的roothttps://blog.csdn.net/fuxuemingzhu/article/details/82084204
782. Partition LabelsMedium使用字典保存每个字符最后出现的位置,如果一个区间内字符的最后位置的都在一起,那么就添加到结果里https://blog.csdn.net/fuxuemingzhu/article/details/79265829
783. Battleships in a BoardMedium直接数有多少小岛就行,判断小岛可以使用它的最左上角元素即可https://blog.csdn.net/fuxuemingzhu/article/details/79403172
784. Complex Number MultiplicationMedium复数运算,重点是分割字符串https://blog.csdn.net/fuxuemingzhu/article/details/79266080
785. Counting BitsMediumi的二进制1个数等于i/2的二进制个数+i%2https://blog.csdn.net/fuxuemingzhu/article/details/70806676
786. Spiral Matrix IIIMedium保留循环更新步数,很恶心https://blog.csdn.net/fuxuemingzhu/article/details/82389223
787. Custom Sort StringMedium统计次数,拼接成字符串https://blog.csdn.net/fuxuemingzhu/article/details/79378688
788. Find All Duplicates in an ArrayMedium原地变成负数,如果已经是负数,那么说明出现了两次。https://blog.csdn.net/fuxuemingzhu/article/details/79275549
789. Design TwitterMedium使用优先级队列弹出最新的内容https://blog.csdn.net/fuxuemingzhu/article/details/82155420
790. Keys and RoomsMedium可以使用DFS和BFS解决https://blog.csdn.net/fuxuemingzhu/article/details/80476862
791. Queue Reconstruction by HeightMedium先插入长得高的他们不会影响别人,然后在对应位置插入次高的https://blog.csdn.net/fuxuemingzhu/article/details/68486884
792. Find Bottom Left Tree ValueMedium层次遍历,找出最后一层的第一个节点即可https://blog.csdn.net/fuxuemingzhu/article/details/70161829
793. Daily TemperaturesMedium使用一个栈,保存每个元素,如果后面的元素比较大,那么就已知出栈操作https://blog.csdn.net/fuxuemingzhu/article/details/79285081
794. Validate Stack SequencesMedium使用栈进行模拟,无论如何都把当前的元素弹出,然后和弹出的元素进行比较,相等的话一直弹出https://blog.csdn.net/fuxuemingzhu/article/details/84495797
795. Find Largest Value in Each Tree RowMedium遍历每一层,找出最大值即可。https://blog.csdn.net/fuxuemingzhu/article/details/70183314
796. Single Element in a Sorted ArrayMedium可以使用很风骚的二分查找k,https://blog.csdn.net/fuxuemingzhu/article/details/79275636
797. Construct Binary Tree from Preorder and Postorder TraversalMedium找到后序的倒数第二个元素就是右子树的根节点https://blog.csdn.net/fuxuemingzhu/article/details/82391321
798. Single Number IIIMedium使用异或或者字典解决https://blog.csdn.net/fuxuemingzhu/article/details/79434100
799. Optimal DivisionMedium这个题非常tricky,没意思https://blog.csdn.net/fuxuemingzhu/article/details/79403723
800. Palindromic SubstringsMedium判断回文,需要判断去掉两头字符之后是否仍然是回文,动态规划https://blog.csdn.net/fuxuemingzhu/article/details/79433960
801. Max Area of IslandMedium找到岛的数量,这个题可以使用BFS或者DFS的方法https://blog.csdn.net/fuxuemingzhu/article/details/79182435
802. Score of ParenthesesMedium可以使用栈和递归,这个题很巧妙,是个不错的题目https://blog.csdn.net/fuxuemingzhu/article/details/84956643
803. Complete Binary Tree InserterMedium使用数组保存每个节点的指针,因为是完全二叉树,所以节点位置除以2就得到了它的父亲节点https://blog.csdn.net/fuxuemingzhu/article/details/82958284
804. Sort Characters By FrequencyMedium根据出现次数排序,然后构建新的字符串即可https://blog.csdn.net/fuxuemingzhu/article/details/79437548
805. Escape The GhostsMedium找出是否存在更小的曼哈顿距离https://blog.csdn.net/fuxuemingzhu/article/details/80480462
806. Binary Tree Inorder TraversalMedium中序遍历本身很简单,但是这个递归的写法不好想https://blog.csdn.net/fuxuemingzhu/article/details/79294461
807. Smallest Subtree with all the Deepest NodesMedium定义递归函数:返回<最大深度,最大深度对应的节点>https://blog.csdn.net/fuxuemingzhu/article/details/82432130
808. Most Frequent Subtree SumMedium遍历求和,字典统计出现次数最多的所有元素http://www.cnblogs.com/grandyang/p/6481682.html
809. Beautiful ArrangementMedium经典回溯法,要背会https://blog.csdn.net/fuxuemingzhu/article/details/79431941
810. Product of Array Except SelfMedium使用两次遍历,分别从左边和右边向中间靠拢https://blog.csdn.net/fuxuemingzhu/article/details/79325534
811. Minimum ASCII Delete Sum for Two StringsMedium和LCS很接近的DP题目https://blog.csdn.net/fuxuemingzhu/article/details/79822689
812. Linked List ComponentsMedium判断当前节点在set中,但是下一个节点不在即可https://blog.csdn.net/fuxuemingzhu/article/details/80479431
813. Top K Frequent ElementsMedium使用字典统计次数,使用优先级队列实现排序https://blog.csdn.net/fuxuemingzhu/article/details/79294073
814. Minimum Moves to Equal Array Elements IIMedium找出中位数,然后求所有数字到中位数的距离和https://blog.csdn.net/fuxuemingzhu/article/details/79437926
815. PermutationsMedium经典回溯法https://blog.csdn.net/fuxuemingzhu/article/details/79363903
816. Teemo AttackingMedium计算每次中毒的开始和结束时间https://blog.csdn.net/fuxuemingzhu/article/details/79438658
817. Generate ParenthesesMedium经典回溯法https://blog.csdn.net/fuxuemingzhu/article/details/79362373
818. MinesweeperMedium扫雷游戏,使用DFShttps://blog.csdn.net/fuxuemingzhu/article/details/79462285
819. Beautiful Arrangement IIMedium每次把后面最大数字放到前面来就能增加一种新的差值https://blog.csdn.net/fuxuemingzhu/article/details/79437401
820. Map Sum PairsMedium前缀树的题目,可以背一背https://blog.csdn.net/fuxuemingzhu/article/details/79436619
821. Friend CirclesMedium并查集的题目https://blog.csdn.net/fuxuemingzhu/article/details/70258103
822. Array NestingMedium一直遍历就好了,使用一个visited数组,但不是回溯。https://blog.csdn.net/fuxuemingzhu/article/details/79460546
823. Most Stones Removed with Same Row or ColumnMedium需要使用并查集,非常考验抽象能力https://blog.csdn.net/fuxuemingzhu/article/details/84500642
824. Mirror ReflectionMedium镜像反射,需要找规律,分偶数和奇数进行讨论https://blog.csdn.net/fuxuemingzhu/article/details/82432579
825. Implement Magic DictionaryMedium找到存不存在汉明间距是1https://blog.csdn.net/fuxuemingzhu/article/details/79447934
826. Rabbits in ForestMedium对兔子出现次数进行统计,然后求一个公式。https://blog.csdn.net/fuxuemingzhu/article/details/79457764
827. Max Chunks To Make SortedMedium从左到右遍历一次,时刻保持当前的最大值,如果当前最大值等于索引,那么chunck+1.https://blog.csdn.net/fuxuemingzhu/article/details/80482014
828. Print Binary TreeMedium先把二叉树构造出来,然后使用类似二分查找左右分治的方法。https://blog.csdn.net/fuxuemingzhu/article/details/79439026
829. Implement Trie (Prefix Tree)Medium构造字典树,是个好题,需要背会https://blog.csdn.net/fuxuemingzhu/article/details/79388432
830. Replace WordsMedium使用字典树或者拉链法求解https://blog.csdn.net/fuxuemingzhu/article/details/79391682
831. Maximum XOR of Two Numbers in an ArrayMedium暴力求解会超时,需要使用异或的性质从最高位开始遍历。或者使用字典树。https://blog.csdn.net/fuxuemingzhu/article/details/79473171
832. Combination SumMedium回溯法,遍历开始的地方不变,要跟踪targethttps://blog.csdn.net/fuxuemingzhu/article/details/79322462
833. Combination Sum IIMedium经典的回溯法,这个题需要背会https://blog.csdn.net/fuxuemingzhu/article/details/79343638
834. Combination Sum IIIMedium也是经典回溯法,需要注意的是不重复,所以递归开始的地方要+1https://blog.csdn.net/fuxuemingzhu/article/details/79343681
835. Combination Sum IVMedium这个题需要使用动态规划求次数了,并不用回溯法。类似于爬楼梯https://blog.csdn.net/fuxuemingzhu/article/details/79343825
836. SubsetsMedium使用回溯法进行搜索,需要注意的是要跟踪现在的位置,不能向回走https://blog.csdn.net/fuxuemingzhu/article/details/79359540
837. Count Numbers with Unique DigitsMedium这个题是找规律+动态规划,要计算1位数字、2位数字…n位数字每位数字都不重复的情况有多少个https://blog.csdn.net/fuxuemingzhu/article/details/80552049
838. CombinationsMedium这个组合问题需要跟踪现在的位置防止向后走,还要跟踪在剩余的数字里面取多少个https://blog.csdn.net/fuxuemingzhu/article/details/80552049
839. Gray CodeMedium格雷码是把比自己小一位的格雷码正向一遍,然后以1开头+小一位的格雷码反向一遍,是个递归过程https://blog.csdn.net/fuxuemingzhu/article/details/80664204
840. Subsets IIMedium这个求子集的时候要屏蔽相同的起始元素,在for循环里进行判断https://blog.csdn.net/fuxuemingzhu/article/details/79785548
841. Letter Combinations of a Phone NumberMedium这个是个排列问题,先把当前位置的所有字符一次排好,然后再排列后面的字符串https://blog.csdn.net/fuxuemingzhu/article/details/79363119
842. Palindrome PartitioningMedium同样的回溯法,如果定义新函数没有太多难度,如果使用题目给定的函数进行递归需要额外判断终止条件https://blog.csdn.net/fuxuemingzhu/article/details/79574462
843. Permutations IIMedium如果当前数字和前面的数字相等,并且前面的数字没有访问过,那么就不能搜索https://blog.csdn.net/fuxuemingzhu/article/details/79513261
844. Restore IP AddressesMedium回溯法,需要考虑ip的各种过滤条件,比如255和0开头的数字不合法https://blog.csdn.net/fuxuemingzhu/article/details/80657420
845. Split Array into Fibonacci SequenceMedium回溯,需要注意不能超过int,和addative numbers很像https://blog.csdn.net/fuxuemingzhu/article/details/80662840
846. Permutation SequenceMedium需要找规律,每一位等于剩余数字/剩余位数的全排列https://blog.csdn.net/fuxuemingzhu/article/details/80658810
847. Word SearchMedium也是经典回溯法,需要保存是否已经访问过了某个位置,总体代码很常见https://blog.csdn.net/fuxuemingzhu/article/details/79386066
848. Add and Search Word - Data structure designMediumTrie加上递归,本身不难,注意遍历所有子节点然后递归的操作https://blog.csdn.net/fuxuemingzhu/article/details/79390052
849. N-Queens IIMedium回溯法去解决。使用一维的数组保存每行放在第多少列,进行有效棋盘判断的时候,需要判断同列或者斜率绝对值1https://blog.csdn.net/fuxuemingzhu/article/details/79517109
850. Shopping OffersMedium使用回溯法进行求解,套餐和单独点都进行尝试,这个题经常考!https://blog.csdn.net/fuxuemingzhu/article/details/82504050
851. Binary Tree Preorder TraversalMedium这个先序遍历迭代解法使用的是栈,有点违反直觉,建议仔细思考思考https://blog.csdn.net/fuxuemingzhu/article/details/72575422
852. Asteroid CollisionMedium栈里保留着向右移动的小行星,如果当前的行星是向左的,向栈里面判断自身是否销毁https://blog.csdn.net/fuxuemingzhu/article/details/81079015
853. Next Greater Element IIMedium单调递减栈,这个题难点在于循环数组,容易分析出把数组过两遍即可,需要求余https://blog.csdn.net/fuxuemingzhu/article/details/79463006
854. Image OverlapMedium正方形重合,使用字典保存两两之间向量的差,求最大的移动向量出现的次数https://blog.csdn.net/fuxuemingzhu/article/details/82597238
855. Minimum Path SumMedium最小路径和,简单的动态规划,注意初始状态https://blog.csdn.net/fuxuemingzhu/article/details/82620422
856. Unique PathsMedium简单的动态规划,给周围包上一圈全0的数字,方便状态转移https://blog.csdn.net/fuxuemingzhu/article/details/79337352
857. Unique Paths IIMedium也是动态规划,和上面的区别在于有障碍物,直接设置障碍物处的状态是0https://blog.csdn.net/fuxuemingzhu/article/details/83154114
858. Rotate ImageMedium先上下翻转,再沿着主对角线翻转即可完成旋转操作https://blog.csdn.net/fuxuemingzhu/article/details/79451733
859. Target SumMedium使用动态规划,dp[i][j]表示到第i个位置位置构成和为j的组合有多少种https://blog.csdn.net/fuxuemingzhu/article/details/80484450
860. Unique Binary Search TreesMedium记忆化递归,动态规划,卡特兰数等等,方法很多https://blog.csdn.net/fuxuemingzhu/article/details/79367789
861. Decode StringMedium字符串解码,需要用到栈保存已经有的字符串和当前的数字,很经典的题目https://blog.csdn.net/fuxuemingzhu/article/details/79332894
862. Group AnagramsMedium对字符串进行排序,排序之后相等的字符串说明包含的字符相等https://blog.csdn.net/fuxuemingzhu/article/details/69831375
863. Task SchedulerMedium任务调度题目,很容易推出公式,但是切记整个时间最少满足任务个数https://blog.csdn.net/fuxuemingzhu/article/details/81947087
864. Best Time to Buy and Sell Stock with CooldownMedium经典动态规划的题目,这个题需要定义两个数组:今天有股票的情况下的收益和今天没有股票情况下的收益,然后状态转移就简单了https://blog.csdn.net/fuxuemingzhu/article/details/82656899
865. Best Time to Buy and Sell Stock with Transaction FeeMedium动态规划,做法和上面非常类似,每次计算收益的时候需要减去手续费https://blog.csdn.net/fuxuemingzhu/article/details/79888528
866. Flatten Binary Tree to Linked ListMedium如果用递归的话一定明白递归函数是把一个二叉树弄平形成链表,然后找到链表尾部,把链表拼接https://blog.csdn.net/fuxuemingzhu/article/details/70241424
867. Longest Increasing SubsequenceMediumLIS问题,是dp最经典的题目之一,需要从每个位置向前遍历以更新dphttps://blog.csdn.net/fuxuemingzhu/article/details/79820919
868. Search a 2D Matrix IIMedium从矩阵的左下或者右上开始遍历,很简单https://blog.csdn.net/fuxuemingzhu/article/details/79459314
869. Search a 2D MatrixMedium在二维数组中进行搜索,可以使用矩阵左下和右上角的查询方法,也可以直接遍历每一个位置。https://blog.csdn.net/fuxuemingzhu/article/details/79459200
870. Perfect SquaresMedium动态规划,一个数字能由多少个整数平方和构成等于满足更小数字+平方数的状态+1。https://blog.csdn.net/fuxuemingzhu/article/details/51284292
871. Partition Equal Subset SumMedium把数字的累计和当做状态,当前的状态等于前面的数字累积和-当前数值的状态。https://blog.csdn.net/fuxuemingzhu/article/details/79787425
872. Contiguous ArrayMedium求累积和,然后判断在这个位置前面,这个累计和是不是出现过https://blog.csdn.net/fuxuemingzhu/article/details/82667054
873. Merge IntervalsMedium使用start和end两个变量表示区间,当区间不再重叠的时候把上面区间放入结果中,重置start和endhttps://blog.csdn.net/fuxuemingzhu/article/details/69078468
874. Course ScheduleMedium拓扑排序,每次弹出入度为0的节点,并把以他为入度的所有节点的入度-1https://blog.csdn.net/fuxuemingzhu/article/details/82951771
875. Construct Binary Tree from Preorder and Inorder TraversalMedium前序遍历的首节点就是根节点,在中序中的位置坐标是左子树,右边是右子树https://blog.csdn.net/fuxuemingzhu/article/details/80775173
876. Lowest Common Ancestor of a Binary TreeMedium这个递归调用需要注意如果查找到任何一个节点都算是找到了最低公共祖先https://blog.csdn.net/fuxuemingzhu/article/details/80778001
877. Word BreakMedium动态规划,每个位置的状态由前面的某个状态+一个条件得到,搜索是两重循环https://blog.csdn.net/fuxuemingzhu/article/details/79368360
878. Minimum Size Subarray SumMedium虫取法,找到最小长度的满足区间https://blog.csdn.net/fuxuemingzhu/article/details/83063096
879. Sort ListMedium对于list的merge sort。https://blog.csdn.net/fuxuemingzhu/article/details/79630742
880. Find First and Last Position of Element in Sorted ArrayMedium自己实现lower_bound和upper_bound函数,使用二分https://blog.csdn.net/fuxuemingzhu/article/details/83273084
881. Search in Rotated Sorted ArrayMedium对二分的进一步理解:判断下一步查找的范围到底在mid左边还是右边https://blog.csdn.net/fuxuemingzhu/article/details/79534213
882. Maximal SquareMedium这个题使用dp,某位置的最大正方形边长等于左边、上边、左上边三个位置最小的边长+1https://blog.csdn.net/fuxuemingzhu/article/details/82992233
883. Jump GameMedium贪心算法,保存每一步都选择跳的最远的地方,如果这个位置不能到达直接返回false.https://blog.csdn.net/fuxuemingzhu/article/details/83504437
884. Find the Duplicate NumberMedium寻找重复的数字,相当于链表中的环,也可以使用二分查找https://blog.csdn.net/fuxuemingzhu/article/details/79530847
885. Linked List Cycle IIMedium找出链表环的入口,可以使用双指针,也可以使用set保存已经遍历过的路径https://blog.csdn.net/fuxuemingzhu/article/details/79530638#set_134
886. Add Two NumbersMedium两个链表的加法,只要有一个链表不空或者进位存在就添加新的节点https://blog.csdn.net/fuxuemingzhu/article/details/79379626
887. Next PermutationMedium找到后面的第一个不降序数字,与第一个比它大的位置进行交换,然后把后面部分翻转即可https://blog.csdn.net/fuxuemingzhu/article/details/82113409
888. Word SearchMedium标准的回溯法,需要向周围进行搜索,同时保存已经遍历了的位置不再访问https://blog.csdn.net/fuxuemingzhu/article/details/79386066
889. Coin ChangeMedium动态规划,定义dp数组是能够成的amount的最少硬币数,遍历硬币更新每个amounthttps://blog.csdn.net/fuxuemingzhu/article/details/83592442
890. Maximum Product SubarrayMedium求连续数组最大积,需要保存每个位置的最大、最小积,每个位置都去维护这两个变量https://blog.csdn.net/fuxuemingzhu/article/details/83211451
891. Longest Palindromic SubstringMedium字符串的简单动态规划,也可以直接暴力求解https://blog.csdn.net/fuxuemingzhu/article/details/79573621
892. Validate Binary Search TreeMedium递归函数中维护每个节点的取值上下限即可。或者有序的中序遍历是个BSThttps://blog.csdn.net/fuxuemingzhu/article/details/70209865
893. Longest Substring Without Repeating CharactersMedium虫取法+set找到每个不含重复元素的子串,保存最长子串https://blog.csdn.net/fuxuemingzhu/article/details/82022530
894. Implement Rand10() Using Rand7()Medium需要先构造出rand40,然后mod10即可得到rand10.https://blog.csdn.net/fuxuemingzhu/article/details/81809478
895. Integer BreakMedium任意>=2的整数都可以拆解成2x+3y,当y尽可能大的时候target = 2x+3y的结果最大https://blog.csdn.net/fuxuemingzhu/article/details/80486238
896. Redundant ConnectionMedium并查集的题目,这种题目是个模板,应该背会DSU的代码https://blog.csdn.net/fuxuemingzhu/article/details/80487064
897. Integer to RomanMedium整数变成罗马数字,把整数进行拆解即可,在拆解的过程中拼接每个数字对应的字符https://blog.csdn.net/fuxuemingzhu/article/details/48210399
898. Kth Smallest Element in a BSTMedium递归解法需要使用全局变量保存已经遍历了多少个了,到达k个时直接停止并返回即可。https://blog.csdn.net/fuxuemingzhu/article/details/69947495
899. Bulb Switcher IIMedium智力题,被踩了很多次,没仔细做https://blog.csdn.net/fuxuemingzhu/article/details/79451356
900. Reordered Power of 2Medium思路要灵活一点,直接统计数字出现的次数是否相等即可,不必真的重新排序https://blog.csdn.net/fuxuemingzhu/article/details/82468653
901. Shuffle an ArrayMediumFisher–Yates 洗牌算法:依次遍历列表中的每一位,并将这一位与其后面的随机一位交换顺序。https://blog.csdn.net/fuxuemingzhu/article/details/79391342
902. Add Two Numbers IIMedium使用额外空间保存两个列表的值元素,然后再模拟加法https://blog.csdn.net/fuxuemingzhu/article/details/79380457
903. Minimum Area RectangleMedium对角线确定长方形,判断另外一条对角线上的两个点是不是存在即可https://leetcode.com/problems/minimum-area-rectangle/
904. Different Ways to Add ParenthesesMedium这是个递归求解的题目,如果遇到一个运算符就把左右两部分分别求出值,然后再做操作。左右部分分别求值求相当于给左右部分分别加上了括号https://blog.csdn.net/fuxuemingzhu/article/details/79568487
905. Design Circular DequeMedium设计deque,最简单的方法是使用双向链表https://blog.csdn.net/fuxuemingzhu/article/details/81027989
906. Random Pick IndexMedium使用蓄水池抽样,每个数字被选择的概率是1/cnt,遍历结束即可https://blog.csdn.net/fuxuemingzhu/article/details/79540576
907. Linked List Random NodeMedium和上题一致,蓄水池抽样https://blog.csdn.net/fuxuemingzhu/article/details/79488113
908. RLE IteratorMedium一个循环,判断当前位置和剩下的数字n之间的关系,看是否向后走即可https://blog.csdn.net/fuxuemingzhu/article/details/82757347
909. Total Hamming DistanceMedium统计int的32位中有多少个数字该位是1、多少个数字该位是0,结果是两者相乘https://blog.csdn.net/fuxuemingzhu/article/details/79494653
910. Split Linked List in PartsMedium求出每一段的长度,然后定一个函数切链表即可https://blog.csdn.net/fuxuemingzhu/article/details/79543931#_57
911. Hand of StraightsMedium使用map保存每个数字的次数,然后向后遍历W-1个数字,判断是否都存在即可https://blog.csdn.net/fuxuemingzhu/article/details/82530857
912. Copy List with Random PointerMedium遍历两遍,第一遍构造的节点放到字典里,第二遍遍历再连接起来https://blog.csdn.net/fuxuemingzhu/article/details/80787528
399. Evaluate DivisionMedium带权有向图的搜索问题https://blog.csdn.net/fuxuemingzhu/article/details/82591165
636. Exclusive Time of FunctionsMedium计算机函数的调度问题,使用栈解决https://blog.csdn.net/fuxuemingzhu/article/details/79537000
646. Maximum Length of Pair ChainMedium这个就是最多能看多少个电视节目的问题,使用的是贪心法,策略是优先选择结束时间早的项目https://blog.csdn.net/fuxuemingzhu/article/details/79826524
328. Odd Even Linked ListMedium先分别构建偶数位置的链表和奇数位置的链表,把对应位置的结果放到对应位置之后,再拼接即可https://blog.csdn.net/fuxuemingzhu/article/details/79569396
638. Shopping OffersMediumDFS进行搜索,尝试每种套餐方案https://blog.csdn.net/fuxuemingzhu/article/details/82504050
318. Maximum Product of Word LengthsMedium直接O(N^2)遍历即可https://blog.csdn.net/fuxuemingzhu/article/details/80932597
173. Binary Search Tree IteratorMedium把每个节点的左孩子放到栈中,遍历栈中节点的时候需要把其右孩子的所有左孩子放到栈中https://blog.csdn.net/fuxuemingzhu/article/details/79436947
337. House Robber IIIMedium递归查找每个节点可不可以用的情况下,最优结果是多少。可不可以用是由父亲节点用没用过决定的,所以递归函数有个变量保存父亲节点的状态。https://blog.csdn.net/fuxuemingzhu/article/details/80779068
343. Integer BreakMedium需要证明把一个数字拆成尽可能多的3和尽可能少的4的和的时候,总乘积最大https://blog.csdn.net/fuxuemingzhu/article/details/80486238
875. Koko Eating BananasMedium这个是一个变相的二分查找,需要根据当前的值判断查找后的移动https://blog.csdn.net/fuxuemingzhu/article/details/82716042
901. Online Stock SpanMedium需要使用一个单调递减栈保存每个数字的前面出现了多少小于等于该数字的数,后来的数字需要吞掉栈中比自己小的数字https://blog.csdn.net/fuxuemingzhu/article/details/82781059
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页