Leetcode 算法题解

本页面是博主leetcode题解集合(无锁的)

  • 最左侧是题AC的情况,打勾的表示已经AC(很久没刷题,又落后了)
  • 目前题解数:327, 可做总数: 601 (题目总数: 734 有锁题数: 133)
  • Title栏目下有链接的就是已经发题解的了,有的题没有写题解,有空的时候补上。
  • 如果要哪一个我还没发的 leetcode题解报告 ,可以留言,博主抽空就写。
  • 有任何疑问欢迎留言^ ^ 博主尽快回复
  • 欢迎指出错误、有更快、更省空间的算法

使用爬虫leetcode_script辅助更新本页面


下面是解题报告~:

# Title Acceptance Difficulty Language
 √ 819 Most Common Word 52.2% Easy C++ / Python
 √ 818 Race Car 23.7% Hard C++ / Python
 √ 817 Linked List Components 47.3% Medium C++ / Python
 √ 816 Ambiguous Coordinates 41.5% Medium C++ / Python
815 Bus Routes 31.1% Hard
814 Binary Tree Pruning 72.6% Medium
813 Largest Sum of Averages 38.0% Medium
812 Largest Triangle Area 52.4% Easy
811 Subdomain Visit Count 65.0% Easy
810 Chalkboard XOR Game 36.0% Hard
809 Expressive Words 35.4% Medium
808 Soup Servings 31.4% Medium
 √ 807 Max Increase to Keep City Skyline 82.1% Medium
 √ 806 Number of Lines To Write String 64.6% Easy
805 Split Array With Same Average 20.1% Hard
 √ 804 Unique Morse Code Words 76.3% Easy
803 Bricks Falling When Hit 20.8% Hard
 √ 802 Find Eventual Safe States 35.9% Medium
 √ 801 Minimum Swaps To Make Sequences Increasing 23.9% Medium
 √ 800 Similar RGB Color 53.5% Easy
 √ 799 Champagne Tower 29.0% Medium C++ / Python
 √ 798 Smallest Rotation with Highest Score 31.5% Hard C++ / Python
 √ 797 All Paths From Source to Target 69.1% Medium Python
 √ 796 Rotate String 54.4% Easy C++ / Python
795 Number of Subarrays with Bounded Maximum 40.6% Medium
794 Valid Tic-Tac-Toe State 27.6% Medium
793 Preimage Size of Factorial Zeroes Function 44.6% Hard
792 Number of Matching Subsequences 35.3% Medium
791 Custom Sort String 60.1% Medium
790 Domino and Tromino Tiling 32.2% Medium
789 Escape The Ghosts 48.2% Medium
788 Rotated Digits 50.5% Easy
787 Cheapest Flights Within K Stops 29.9% Medium
786 K-th Smallest Prime Fraction 30.0% Hard
785 Is Graph Bipartite? 38.9% Medium
784 Letter Case Permutation 52.4% Easy
783 Minimum Distance Between BST Nodes 47.3% Easy
782 Transform to Chessboard 35.8% Hard
781 Rabbits in Forest 49.4% Medium
780 Reaching Points 22.3% Hard
779 K-th Symbol in Grammar 36.1% Medium
778 Swim in Rising Water 44.4% Hard
777 Swap Adjacent in LR String 27.8% Medium
775 Global and Local Inversions 31.7% Medium
773 Sliding Puzzle 47.6% Hard
771 Jewels and Stones 82.1% Easy
770 Basic Calculator IV 43.2% Hard
769 Max Chunks To Make Sorted 47.8% Medium
768 Max Chunks To Make Sorted II 42.9% Hard
767 Reorganize String 35.6% Medium
766 Toeplitz Matrix 57.7% Easy
765 Couples Holding Hands 48.3% Hard
764 Largest Plus Sign 37.4% Medium
763 Partition Labels 64.2% Medium
762 Prime Number of Set Bits in Binary Representation 55.0% Easy
761 Special Binary String 41.6% Hard
757 Set Intersection Size At Least Two 34.8% Hard
756 Pyramid Transition Matrix 45.8% Medium
754 Reach a Number 26.6% Medium
753 Cracking the Safe 39.8% Hard
752 Open the Lock 38.6% Medium
749 Contain Virus 39.7% Hard
748 Shortest Completing Word 51.9% Medium
747 Largest Number At Least Twice of Others 41.8% Easy
746 Min Cost Climbing Stairs 43.3% Easy
745 Prefix and Suffix Search 25.4% Hard
744 Find Smallest Letter Greater Than Target 44.0% Easy
743 Network Delay Time 35.1% Medium
741 Cherry Pickup 23.7% Hard
740 Delete and Earn 43.9% Medium
739 Daily Temperatures 52.5% Medium
738 Monotone Increasing Digits 40.8% Medium
736 Parse Lisp Expression 43.0% Hard
735 Asteroid Collision 37.0% Medium
733 Flood Fill 47.9% Easy
732 My Calendar III 50.9% Hard
731 My Calendar II 37.6% Medium
730 Count Different Palindromic Subsequences 35.1% Hard
 √ 729 My Calendar I 42.4% Medium
728 Self Dividing Numbers 66.7% Easy
726 Number of Atoms 43.8% Hard
725 Split Linked List in Parts 47.3% Medium
724 Find Pivot Index 39.4% Easy
722 Remove Comments 27.9% Medium
721 Accounts Merge 32.9% Medium
720 Longest Word in Dictionary 41.4% Easy
 √ 719 Find K-th Smallest Pair Distance 27.0% Hard
 √ 718 Maximum Length of Repeated Subarray 41.5% Medium Java / Python
 √ 717 1-bit and 2-bit Characters 49.5% Easy C++
 √ 715 Range Module 31.2% Hard
 √ 714 Best Time to Buy and Sell Stock with Transaction Fee 45.5% Medium C++ / Java / Python
 √ 713 Subarray Product Less Than K 33.2% Medium C++ / Java / Python
 √ 712 Minimum ASCII Delete Sum for Two Strings 51.3% Medium C++ / Java / Python
 √ 699 Falling Squares 37.3% Hard C++ / Python
 √ 698 Partition to K Equal Sum Subsets 37.8% Medium Java
 √ 697 Degree of an Array 46.6% Easy Python
 √ 696 Count Binary Substrings 50.8% Easy Python
 √ 695 Max Area of Island 51.8% Easy Python
 √ 694 Number of Distinct Islands 45.2% Medium
 √ 693 Binary Number with Alternating Bits 55.7% Easy Python
 √ 692 Top K Frequent Words 41.3% Medium
 √ 691 Stickers to Spell Word 34.8% Hard Python
 √ 690 Employee Importance 51.6% Easy
 √ 689 Maximum Sum of 3 Non-Overlapping Subarrays 41.0% Hard Python
 √ 688 Knight Probability in Chessboard 40.0% Medium Python
 √ 687 Longest Univalue Path 32.9% Easy Python
 √ 686 Repeated String Match 32.2% Easy Python
 √ 685 Redundant Connection II 27.9% Hard
 √ 684 Redundant Connection 43.7% Medium
 √ 683 K Empty Slots 34.4% Hard
 √ 682 Baseball Game 58.0% Easy
 √ 681 Next Closest Time 42.0% Medium
 √ 680 Valid Palindrome II 32.2% Easy
 √ 679 24 Game 38.7% Hard
 √ 678 Valid Parenthesis String 29.5% Medium
 √ 677 Map Sum Pairs 51.6% Medium
 √ 676 Implement Magic Dictionary 49.1% Medium
 √ 675 Cut Off Trees for Golf Event 27.0% Hard
 √ 674 Longest Continuous Increasing Subsequence 42.4% Easy
 √ 673 Number of Longest Increasing Subsequence 31.6% Medium
 √ 672 Bulb Switcher II 49.5% Medium
 √ 671 Second Minimum Node In a Binary Tree 41.8% Easy
 √ 670 Maximum Swap 38.6% Medium
 √ 669 Trim a Binary Search Tree 58.0% Easy
 √ 668 Kth Smallest Number in Multiplication Table 40.1% Hard
 √ 667 Beautiful Arrangement II 51.4% Medium
 √ 665 Non-decreasing Array 20.3% Easy
 √ 664 Strange Printer 34.1% Hard
 √ 663 Equal Tree Partition 36.7% Medium
 √ 662 Maximum Width of Binary Tree 38.1% Medium
 √ 661 Image Smoother 46.0% Easy
 √ 660 Remove 9 49.5% Hard
 √ 659 Split Array into Consecutive Subsequences 37.0% Medium
 √ 658 Find K Closest Elements 35.0% Medium
 √ 657 Judge Route Circle 68.5% Easy
 √ 655 Print Binary Tree 49.2% Medium
 √ 654 Maximum Binary Tree 69.9% Medium
 √ 653 Two Sum IV – Input is a BST 50.0% Easy
 √ 652 Find Duplicate Subtrees 36.8% Medium
 √ 650 2 Keys Keyboard 44.9% Medium
 √ 649 Dota2 Senate 36.7% Medium
 √ 648 Replace Words 47.8% Medium
 √ 647 Palindromic Substrings 54.7% Medium
 √ 646 Maximum Length of Pair Chain 47.2% Medium
 √ 645 Set Mismatch 39.6% Easy
 √ 643 Maximum Average Subarray I 37.5% Easy
 √ 640 Solve the Equation 38.6% Medium
 √ 639 Decode Ways II 24.4% Hard
 √ 638 Shopping Offers 45.1% Medium
 √ 637 Average of Levels in Binary Tree 55.8% Easy
 √ 636 Exclusive Time of Functions 44.6% Medium
 √ 633 Sum of Square Numbers 32.3% Easy
 √ 632 Smallest Range 41.9% Hard
 √ 630 Course Schedule III 29.4% Hard
 √ 629 K Inverse Pairs Array 27.3% Hard
 √ 628 Maximum Product of Three Numbers 44.6% Easy
 √ 623 Add One Row to Tree 46.2% Medium
 √ 621 Task Scheduler 42.4% Medium
 √ 617 Merge Two Binary Trees 67.5% Easy
 √ 611 Valid Triangle Number 42.1% Medium
 √ 609 Find Duplicate File in System 52.2% Medium
 √ 606 Construct String from Binary Tree 49.7% Easy
 √ 605 Can Place Flowers 30.1% Easy
 √ 600 Non-negative Integers without Consecutive Ones 31.7% Hard
 √ 599 Minimum Index Sum of Two Lists 46.4% Easy
 √ 598 Range Addition II 48.1% Easy
 √ 594 Longest Harmonious Subsequence 41.1% Easy
 √ 593 Valid Square 39.9% Medium
 √ 592 Fraction Addition and Subtraction 46.0% Medium
 √ 591 Tag Validator 31.0% Hard
 √ 587 Erect the Fence 33.7% Hard
 √ 583 Delete Operation for Two Strings 44.5% Medium
 √ 582 Kill Process 50.8% Medium
 √ 581 Shortest Unsorted Continuous Subarray 29.1% Easy
 √ 576 Out of Boundary Paths 30.6% Medium
 √ 575 Distribute Candies 58.0% Easy
 √ 572 Subtree of Another Tree 40.2% Easy
 √ 567 Permutation in String 36.3% Medium
 √ 566 Reshape the Matrix 57.6% Easy
 √ 565 Array Nesting 49.3% Medium
 √ 564 Find the Closest Palindrome 17.2% Hard
 √ 563 Binary Tree Tilt 47.2% Easy
 √ 561 Array Partition I 66.3% Easy
 √ 560 Subarray Sum Equals K 39.9% Medium
 √ 557 Reverse Words in a String III 60.0% Easy
 √ 556 Next Greater Element III 29.0% Medium
 √ 554 Brick Wall 46.5% Medium
 √ 553 Optimal Division 55.2% Medium
 √ 552 Student Attendance Record II 31.6% Hard
 √ 551 Student Attendance Record I 44.6% Easy
 √ 547 Friend Circles 49.1% Medium
 √ 546 Remove Boxes 35.4% Hard
 √ 544 Output Contest Matches 71.4% Medium
 √ 543 Diameter of Binary Tree 44.9% Easy Python
 √ 542 01 Matrix 33.0% Medium Python
 √ 541 Reverse String II 43.9% Easy
 √ 540 Single Element in a Sorted Array 55.9% Medium
 √ 539 Minimum Time Difference 46.1% Medium
 √ 538 Convert BST to Greater Tree 48.7% Easy Python
 √ 537 Complex Number Multiplication 63.6% Medium
 √ 535 Encode and Decode TinyURL 73.8% Medium
 √ 532 K-diff Pairs in an Array 28.1% Easy
 √ 530 Minimum Absolute Difference in BST 47.4% Easy
 √ 529 Minesweeper 49.5% Medium
 √ 526 Beautiful Arrangement 53.2% Medium
 √ 525 Contiguous Array 41.4% Medium
 √ 524 Longest Word in Dictionary through Deleting 43.3% Medium
 √ 523 Continuous Subarray Sum 23.3% Medium
 √ 522 Longest Uncommon Subsequence II 32.0% Medium
 √ 521 Longest Uncommon Subsequence I 55.7% Easy
 √ 520 Detect Capital 51.9% Easy
 √ 517 Super Washing Machines 36.3% Hard
 √ 516 Longest Palindromic Subsequence 42.8% Medium
 √ 515 Find Largest Value in Each Tree Row 55.5% Medium
 √ 514 Freedom Trail 39.3% Hard
 √ 513 Find Bottom Left Tree Value 56.1% Medium
 √ 508 Most Frequent Subtree Sum 52.2% Medium
 √ 507 Perfect Number 32.5% Easy
 √ 506 Relative Ranks 46.9% Easy
 √ 504 Base 7 43.9% Easy
 √ 503 Next Greater Element II 48.1% Medium
 √ 502 IPO 36.4% Hard
 √ 501 Find Mode in Binary Search Tree 37.5% Easy
 √ 500 Keyboard Row 59.9% Easy
 √ 498 Diagonal Traverse 46.2% Medium
 √ 496 Next Greater Element I 56.5% Easy
 √ 495 Teemo Attacking 51.4% Medium
 √ 494 Target Sum 43.8% Medium
 √ 493 Reverse Pairs 20.8% Hard
 √ 492 Construct the Rectangle 48.0% Easy
 √ 491 Increasing Subsequences 38.8% Medium
 √ 488 Zuma Game 37.2% Hard
 √ 486 Predict the Winner 45.1% Medium
 √ 485 Max Consecutive Ones 53.8% Easy
 √ 483 Smallest Good Base 33.7% Hard
 √ 482 License Key Formatting 39.6% Easy
 √ 481 Magical String 45.8% Medium
 √ 480 Sliding Window Median 30.8% Hard
 √ 479 Largest Palindrome Product 25.6% Easy
 √ 477 Total Hamming Distance 47.5% Medium
 √ 476 Number Complement 61.1% Easy
 √ 475 Heaters 29.7% Easy
 √ 474 Ones and Zeroes 38.8% Medium
 √ 473 Matchsticks to Square 35.3% Medium
 √ 472 Concatenated Words 31.0% Hard
 √ 468 Validate IP Address 20.6% Medium
 √ 467 Unique Substrings in Wraparound String 33.2% Medium
 √ 466 Count The Repetitions 27.3% Hard
 √ 464 Can I Win 25.3% Medium
 √ 463 Island Perimeter 57.9% Easy
 √ 462 Minimum Moves to Equal Array Elements II 51.8% Medium
 √ 461 Hamming Distance 69.5% Easy
 √ 460 LFU Cache 25.1% Hard
 √ 459 Repeated Substring Pattern 38.2% Easy
 √ 456 132 Pattern 27.8% Medium
 √ 455 Assign Cookies 47.2% Easy
 √ 454 4Sum II 47.6% Medium
 √ 453 Minimum Moves to Equal Array Elements 48.0% Easy
 √ 452 Minimum Number of Arrows to Burst Balloons 44.5% Medium
 √ 451 Sort Characters By Frequency 51.7% Medium
 √ 450 Delete Node in a BST 37.8% Medium
 √ 449 Serialize and Deserialize BST 43.0% Medium C++ / Java / Python
 √ 448 Find All Numbers Disappeared in an Array 51.1% Easy
 √ 447 Number of Boomerangs 46.7% Easy
 √ 446 Arithmetic Slices II – Subsequence 28.0% Hard
 √ 445 Add Two Numbers II 46.2% Medium
443 String Compression 35.9% Easy
 √ 442 Find All Duplicates in an Array 57.0% Medium
 √ 441 Arranging Coins 36.5% Easy
 √ 440 K-th Smallest in Lexicographical Order 25.7% Hard
 √ 438 Find All Anagrams in a String 33.9% Easy
 √ 437 Path Sum III 40.2% Easy
 √ 436 Find Right Interval 41.5% Medium
 √ 435 Non-overlapping Intervals 41.2% Medium
 √ 434 Number of Segments in a String 36.6% Easy
 √ 432 All O`one Data Structure 28.0% Hard C++ / Java / Python
 √ 424 Longest Repeating Character Replacement 42.6% Medium
 √ 423 Reconstruct Original Digits from English 44.7% Medium
 √ 421 Maximum XOR of Two Numbers in an Array 48.0% Medium
 √ 420 Strong Password Checker 19.8% Hard
 √ 419 Battleships in a Board 63.1% Medium
 √ 417 Pacific Atlantic Water Flow 34.8% Medium
 √ 416 Partition Equal Subset Sum 38.9% Medium
 √ 415 Add Strings 41.8% Easy
 √ 414 Third Maximum Number 28.1% Easy
 √ 413 Arithmetic Slices 54.5% Medium
 √ 412 Fizz Buzz 58.1% Easy
 √ 410 Split Array Largest Sum 39.4% Hard
 √ 409 Longest Palindrome 46.0% Easy
 √ 407 Trapping Rain Water II 37.9% Hard
 √ 406 Queue Reconstruction by Height 56.5% Medium
 √ 405 Convert a Number to Hexadecimal 41.0% Easy
 √ 404 Sum of Left Leaves 47.5% Easy
 √ 403 Frog Jump 32.6% Hard Python
 √ 402 Remove K Digits 25.8% Medium Python
 √ 401 Binary Watch 44.8% Easy Python
 √ 400 Nth Digit 30.2% Easy Python
 √ 399 Evaluate Division 42.4% Medium Python
 √ 398 Random Pick Index 44.7% Medium Python
 √ 397 Integer Replacement 30.5% Medium Python
 √ 396 Rotate Function 33.8% Medium Python
 √ 395 Longest Substring with At Least K Repeating Characters 35.7% Medium C++ / Python
 √ 394 Decode String 42.1% Medium Python
 √ 393 UTF-8 Validation 34.8% Medium Python
 √ 392 Is Subsequence 44.7% Medium C++ / Java / Python
 √ 391 Perfect Rectangle 27.5% Hard Python
 √ 390 Elimination Game 42.6% Medium Python
 √ 389 Find the Difference 51.3% Easy Python
 √ 388 Longest Absolute File Path 37.5% Medium Python
 √ 387 First Unique Character in a String 47.1% Easy Python
 √ 386 Lexicographical Numbers 42.3% Medium Python
 √ 385 Mini Parser 30.9% Medium Python
 √ 384 Shuffle an Array 47.3% Medium C++ / Java / Python
 √ 383 Ransom Note 47.8% Easy C++ / Java / Python
 √ 382 Linked List Random Node 47.4% Medium C++ / Java / Python
 √ 381 Insert Delete GetRandom O(1) – Duplicates allowed 29.7% Hard C++ / Python
 √ 380 Insert Delete GetRandom O(1) 39.9% Medium Python
 √ 378 Kth Smallest Element in a Sorted Matrix 45.5% Medium C++ / Java / Python
 √ 377 Combination Sum IV 42.7% Medium C++ / Java / Python
 √ 376 Wiggle Subsequence 36.1% Medium C++ / Java / Python
 √ 375 Guess Number Higher or Lower II 36.1% Medium C++ / Java / Python
 √ 374 Guess Number Higher or Lower 36.7% Easy C++ / Java / Python
 √ 373 Find K Pairs with Smallest Sums 31.3% Medium C++
 √ 372 Super Pow 34.8% Medium C++ / Java / Python
 √ 371 Sum of Two Integers 50.9% Easy C++ / Java / Python
 √ 368 Largest Divisible Subset 33.9% Medium C++ / Java / Python
 √ 367 Valid Perfect Square 38.7% Easy C++ / Java / Python
 √ 365 Water and Jug Problem 28.0% Medium C++ / Java / Python
 √ 363 Max Sum of Rectangle No Larger Than K 33.8% Hard C++
 √ 357 Count Numbers with Unique Digits 46.1% Medium C++ / Java / Python
 √ 355 Design Twitter 25.8% Medium Python
 √ 354 Russian Doll Envelopes 32.6% Hard C++ / Python
 √ 352 Data Stream as Disjoint Intervals 41.1% Hard Java
 √ 350 Intersection of Two Arrays II 44.3% Easy Python
 √ 349 Intersection of Two Arrays 48.3% Easy C++ / Java / Python
 √ 347 Top K Frequent Elements 49.6% Medium C++ / Python
 √ 345 Reverse Vowels of a String 39.2% Easy C++
 √ 344 Reverse String 60.4% Easy C++ / Python
 √ 343 Integer Break 46.5% Medium Python
 √ 342 Power of Four 39.2% Easy C++ / Java / Python
 √ 341 Flatten Nested List Iterator 43.2% Medium
 √ 338 Counting Bits 62.2% Medium C++ / Java / Python
 √ 337 House Robber III 44.7% Medium C++ / Java / Python
 √ 336 Palindrome Pairs 27.2% Hard Python
 √ 335 Self Crossing 26.2% Hard C++ / Java / Python
 √ 334 Increasing Triplet Subsequence 39.7% Medium C++ / Java / Python
 √ 332 Reconstruct Itinerary 29.9% Medium C++ / Python
 √ 331 Verify Preorder Serialization of a Binary Tree 37.1% Medium Java / Python
 √ 330 Patching Array 32.7% Hard C++ / Java / Python
 √ 329 Longest Increasing Path in a Matrix 37.5% Hard C++ / Java / Python
 √ 328 Odd Even Linked List 44.8% Medium C++ / Java / Python
 √ 327 Count of Range Sum 30.7% Hard C++ / Python
 √ 326 Power of Three 40.7% Easy C++ / Java / Python
 √ 324 Wiggle Sort II 26.4% Medium Java / Python
 √ 322 Coin Change 26.6% Medium C++ / Java / Python
 √ 321 Create Maximum Number 24.8% Hard C++ / Java / Python
 √ 319 Bulb Switcher 43.0% Medium C++ / Java / Python
 √ 318 Maximum Product of Word Lengths 45.7% Medium C++ / Java / Python
 √ 316 Remove Duplicate Letters 30.4% Hard Python
 √ 315 Count of Smaller Numbers After Self 35.0% Hard
 √ 313 Super Ugly Number 38.3% Medium C++ / Java / Python
 √ 312 Burst Balloons 43.7% Hard
 √ 310 Minimum Height Trees 29.0% Medium
 √ 309 Best Time to Buy and Sell Stock with Cooldown 42.0% Medium
 √ 307 Range Sum Query – Mutable 22.6% Medium
 √ 306 Additive Number 27.7% Medium
 √ 304 Range Sum Query 2D – Immutable 27.3% Medium
 √ 303 Range Sum Query – Immutable 32.2% Easy
 √ 301 Remove Invalid Parentheses 35.9% Hard
 √ 300 Longest Increasing Subsequence 38.9% Medium
 √ 299 Bulls and Cows 36.0% Medium
 √ 297 Serialize and Deserialize Binary Tree 35.1% Hard C++ / Java / Python
 √ 295 Find Median from Data Stream 29.6% Hard
 √ 292 Nim Game 55.4% Easy
 √ 290 Word Pattern 33.5% Easy
 √ 289 Game of Life 37.3% Medium
 √ 287 Find the Duplicate Number 44.3% Medium
 √ 284 Peeking Iterator 35.5% Medium
 √ 283 Move Zeroes 51.6% Easy
 √ 282 Expression Add Operators 30.6% Hard
 √ 279 Perfect Squares 37.8% Medium
 √ 278 First Bad Version 25.9% Easy
 √ 275 H-Index II 34.9% Medium Python
 √ 274 H-Index 33.7% Medium C++ / Python
 √ 273 Integer to English Words 22.8% Hard
 √ 268 Missing Number 45.1% Easy C++ / Python
 √ 264 Ugly Number II 33.3% Medium C++ / Java / Python
 √ 263 Ugly Number 39.7% Easy C++ / Java / Python
 √ 260 Single Number III 53.2% Medium
 √ 258 Add Digits 51.8% Easy C++ / Python
 √ 257 Binary Tree Paths 41.3% Easy
 √ 242 Valid Anagram 47.5% Easy
 √ 241 Different Ways to Add Parentheses 46.1% Medium
 √ 240 Search a 2D Matrix II 39.1% Medium C++ / Java / Python
 √ 239 Sliding Window Maximum 34.2% Hard
 √ 238 Product of Array Except Self 50.3% Medium C++ / Java / Python
 √ 237 Delete Node in a Linked List 47.2% Easy
 √ 236 Lowest Common Ancestor of a Binary Tree 29.9% Medium Python
 √ 235 Lowest Common Ancestor of a Binary Search Tree 39.8% Easy Python
 √ 234 Palindrome Linked List 33.5% Easy
 √ 233 Number of Digit One 29.0% Hard
 √ 232 Implement Queue using Stacks 38.1% Easy
 √ 231 Power of Two 40.8% Easy
 √ 230 Kth Smallest Element in a BST 45.3% Medium
 √ 229 Majority Element II 29.2% Medium
 √ 228 Summary Ranges 32.1% Medium
 √ 227 Basic Calculator II 30.1% Medium
 √ 226 Invert Binary Tree 53.3% Easy
 √ 225 Implement Stack using Queues 34.4% Easy
 √ 224 Basic Calculator 28.7% Hard
 √ 223 Rectangle Area 33.8% Medium
 √ 222 Count Complete Tree Nodes 27.7% Medium
 √ 221 Maximal Square 30.4% Medium
 √ 220 Contains Duplicate III 18.8% Medium C++ / Java / Python
 √ 219 Contains Duplicate II 32.9% Easy C++ / Java / Python
 √ 218 The Skyline Problem 29.1% Hard
 √ 217 Contains Duplicate 47.1% Easy C++ / Java / Python
 √ 216 Combination Sum III 47.3% Medium
 √ 215 Kth Largest Element in an Array 40.6% Medium
 √ 214 Shortest Palindrome 25.2% Hard
 √ 213 House Robber II 34.6% Medium
 √ 212 Word Search II 24.8% Hard
 √ 211 Add and Search Word – Data structure design 25.4% Medium
 √ 210 Course Schedule II 30.3% Medium
 √ 209 Minimum Size Subarray Sum 32.1% Medium C++ / Java / Python
 √ 208 Implement Trie (Prefix Tree) 31.0% Medium
 √ 207 Course Schedule 33.8% Medium
 √ 206 Reverse Linked List 46.8% Easy
 √ 205 Isomorphic Strings 34.8% Easy
 √ 204 Count Primes 26.5% Easy C++ / Java / Python
 √ 203 Remove Linked List Elements 33.5% Easy
 √ 202 Happy Number 41.6% Easy
 √ 201 Bitwise AND of Numbers Range 34.5% Medium
 √ 200 Number of Islands 36.6% Medium
 √ 199 Binary Tree Right Side View 42.5% Medium
 √ 198 House Robber 40.0% Easy
 √ 191 Number of 1 Bits 40.4% Easy
 √ 190 Reverse Bits 29.4% Easy
 √ 189 Rotate Array 25.3% Easy
 √ 188 Best Time to Buy and Sell Stock IV 24.9% Hard
 √ 187 Repeated DNA Sequences 33.1% Medium
 √ 179 Largest Number 23.5% Medium C++ / Java / Python
 √ 174 Dungeon Game 24.2% Hard
 √ 173 Binary Search Tree Iterator 43.6% Medium
 √ 172 Factorial Trailing Zeroes 37.0% Easy
 √ 171 Excel Sheet Column Number 48.5% Easy
 √ 169 Majority Element 48.0% Easy
 √ 168 Excel Sheet Column Title 27.3% Easy
 √ 167 Two Sum II – Input array is sorted 47.2% Easy C++ / Java / Python
 √ 166 Fraction to Recurring Decimal 18.1% Medium
 √ 165 Compare Version Numbers 20.8% Medium
 √ 164 Maximum Gap 30.1% Hard
 √ 162 Find Peak Element 38.9% Medium
 √ 160 Intersection of Two Linked Lists 30.9% Easy C / C++ / Java / Python
 √ 155 Min Stack 31.3% Easy
 √ 154 Find Minimum in Rotated Sorted Array II 37.9% Hard
 √ 153 Find Minimum in Rotated Sorted Array 40.9% Medium
 √ 152 Maximum Product Subarray 26.8% Medium
 √ 151 Reverse Words in a String 15.6% Medium
 √ 150 Evaluate Reverse Polish Notation 28.5% Medium
 √ 149 Max Points on a Line 15.2% Hard
 √ 148 Sort List 29.9% Medium
 √ 147 Insertion Sort List 33.9% Medium
 √ 146 LRU Cache 19.9% Hard
 √ 145 Binary Tree Postorder Traversal 42.3% Hard
 √ 144 Binary Tree Preorder Traversal 46.9% Medium
 √ 143 Reorder List 26.8% Medium
 √ 142 Linked List Cycle II 30.6% Medium C++ / Java / Python
 √ 141 Linked List Cycle 35.0% Easy C / C++ / Java / Python
 √ 140 Word Break II 24.6% Hard
 √ 139 Word Break 31.5% Medium
 √ 138 Copy List with Random Pointer 25.8% Medium
 √ 137 Single Number II 42.7% Medium
 √ 136 Single Number 55.4% Easy
 √ 135 Candy 25.3% Hard
 √ 134 Gas Station 30.0% Medium
 √ 133 Clone Graph 25.2% Medium
 √ 132 Palindrome Partitioning II 24.9% Hard C++ / Java / Python
 √ 131 Palindrome Partitioning 35.7% Medium
 √ 130 Surrounded Regions 19.7% Medium
 √ 129 Sum Root to Leaf Numbers 37.8% Medium
 √ 128 Longest Consecutive Sequence 38.3% Hard
 √ 127 Word Ladder 20.1% Medium
 √ 126 Word Ladder II 14.9% Hard
 √ 125 Valid Palindrome 27.0% Easy
 √ 124 Binary Tree Maximum Path Sum 27.2% Hard
 √ 123 Best Time to Buy and Sell Stock III 30.4% Hard
 √ 122 Best Time to Buy and Sell Stock II 47.7% Easy
 √ 121 Best Time to Buy and Sell Stock 42.9% Easy
 √ 120 Triangle 34.9% Medium C++ / Python
 √ 119 Pascal’s Triangle II 38.2% Easy C++ / Python
 √ 118 Pascal’s Triangle 40.1% Easy C++ / Python
 √ 117 Populating Next Right Pointers in Each Node II 33.9% Medium
 √ 116 Populating Next Right Pointers in Each Node 36.8% Medium
 √ 115 Distinct Subsequences 32.1% Hard C++ / Python
 √ 114 Flatten Binary Tree to Linked List 36.6% Medium C++ / Python
 √ 113 Path Sum II 35.7% Medium C++ / Python
 √ 112 Path Sum 35.0% Easy
 √ 111 Minimum Depth of Binary Tree 33.6% Easy
 √ 110 Balanced Binary Tree 38.5% Easy C++ / Python
 √ 109 Convert Sorted List to Binary Search Tree 35.8% Medium C++ / Java / Python
 √ 108 Convert Sorted Array to Binary Search Tree 44.6% Easy C++ / Java / Python
 √ 107 Binary Tree Level Order Traversal II 42.2% Easy C++ / Python
 √ 106 Construct Binary Tree from Inorder and Postorder Traversal 33.7% Medium
 √ 105 Construct Binary Tree from Preorder and Inorder Traversal 34.2% Medium
 √ 104 Maximum Depth of Binary Tree 55.0% Easy C++ / Python
 √ 103 Binary Tree Zigzag Level Order Traversal 36.8% Medium C++ / Python
 √ 102 Binary Tree Level Order Traversal 42.7% Medium C++ / Python
 √ 101 Symmetric Tree 40.4% Easy C++ / Python
 √ 100 Same Tree 47.8% Easy C++ / Python
 √ 99 Recover Binary Search Tree 31.1% Hard
 √ 98 Validate Binary Search Tree 24.1% Medium
 √ 97 Interleaving String 25.2% Hard C++ / Python
 √ 96 Unique Binary Search Trees 42.0% Medium
 √ 95 Unique Binary Search Trees II 32.3% Medium
 √ 94 Binary Tree Inorder Traversal 49.8% Medium
 √ 93 Restore IP Addresses 28.5% Medium
 √ 92 Reverse Linked List II 31.4% Medium
 √ 91 Decode Ways 20.3% Medium C++ / Python
 √ 90 Subsets II 38.3% Medium C++ / Java / Python
 √ 89 Gray Code 42.5% Medium C++ / Python
 √ 88 Merge Sorted Array 32.1% Easy C++ / Python
 √ 87 Scramble String 29.7% Hard C++ / Python
 √ 86 Partition List 33.5% Medium C++ / Python
 √ 85 Maximal Rectangle 29.7% Hard C++ / Python
 √ 84 Largest Rectangle in Histogram 27.6% Hard C++ / Python
 √ 83 Remove Duplicates from Sorted List 40.3% Easy C++ / Python
 √ 82 Remove Duplicates from Sorted List II 30.0% Medium C++ / Python
 √ 81 Search in Rotated Sorted Array II 32.7% Medium C++ / Python
 √ 80 Remove Duplicates from Sorted Array II 36.8% Medium C++ / Python
 √ 79 Word Search 28.1% Medium C++ / Python
 √ 78 Subsets 44.9% Medium C++ / Java / Python
 √ 77 Combinations 41.3% Medium C++ / Java / Python
 √ 76 Minimum Window Substring 26.8% Hard C++ / Python
 √ 75 Sort Colors 38.9% Medium C++ / Python
 √ 74 Search a 2D Matrix 34.6% Medium C++ / Python
 √ 73 Set Matrix Zeroes 36.5% Medium C++ / Python
 √ 72 Edit Distance 32.6% Hard C++ / Java / Python
 √ 71 Simplify Path 26.3% Medium
 √ 70 Climbing Stairs 41.3% Easy C++ / Python
 √ 69 Sqrt(x) 28.9% Easy C++ / Python
 √ 68 Text Justification 20.0% Hard C++ / Python
 √ 67 Add Binary 34.1% Easy C++ / Python
 √ 66 Plus One 39.8% Easy C++ / Python
 √ 65 Valid Number 12.9% Hard
 √ 64 Minimum Path Sum 40.8% Medium C++ / Python
 √ 63 Unique Paths II 32.2% Medium C++ / Python
 √ 62 Unique Paths 42.9% Medium C++ / Python
 √ 61 Rotate List 24.5% Medium C++ / Python
 √ 60 Permutation Sequence 29.5% Medium
 √ 59 Spiral Matrix II 41.0% Medium
 √ 58 Length of Last Word 32.1% Easy C++ / Python
 √ 57 Insert Interval 29.0% Hard C++ / Python
 √ 56 Merge Intervals 32.0% Medium C++ / Python
 √ 55 Jump Game 29.5% Medium C++ / Python
 √ 54 Spiral Matrix 27.3% Medium
 √ 53 Maximum Subarray 40.3% Easy
 √ 52 N-Queens II 46.9% Hard
 √ 51 N-Queens 33.3% Hard
 √ 50 Pow(x, n) 26.0% Medium
 √ 49 Group Anagrams 38.5% Medium
 √ 48 Rotate Image 41.9% Medium C++ / Python
 √ 47 Permutations II 35.1% Medium C++ / Java / Python
 √ 46 Permutations 47.4% Medium C++ / Java / Python
 √ 45 Jump Game II 26.1% Hard C++ / Python
 √ 44 Wildcard Matching 21.0% Hard
 √ 43 Multiply Strings 28.0% Medium
 √ 42 Trapping Rain Water 37.6% Hard C++ / Java / Python
 √ 41 First Missing Positive 25.8% Hard C++ / Python
 √ 40 Combination Sum II 36.0% Medium C++ / Java / Python
 √ 39 Combination Sum 41.5% Medium C++ / Java / Python
 √ 38 Count and Say 36.8% Easy C++ / Python
 √ 37 Sudoku Solver 32.1% Hard C++ / Python
 √ 36 Valid Sudoku 37.6% Medium C++ / Python
 √ 35 Search Insert Position 40.0% Easy C++ / Python
 √ 34 Search for a Range 31.6% Medium C++ / Python
 √ 33 Search in Rotated Sorted Array 31.9% Medium C++ / Python
 √ 32 Longest Valid Parentheses 23.2% Hard
 √ 31 Next Permutation 29.1% Medium C++ / Java / Python
 √ 30 Substring with Concatenation of All Words 22.3% Hard C++ / Python
 √ 29 Divide Two Integers 15.7% Medium C++ / Python
 √ 28 Implement strStr() 29.0% Easy C++ / Python
 √ 27 Remove Element 40.8% Easy C++ / Python
 √ 26 Remove Duplicates from Sorted Array 36.4% Easy C++ / Python
 √ 25 Reverse Nodes in k-Group 31.7% Hard C++
 √ 24 Swap Nodes in Pairs 39.2% Medium C++
 √ 23 Merge k Sorted Lists 28.1% Hard C++ / Python
 √ 22 Generate Parentheses 48.1% Medium C++ / Python
 √ 21 Merge Two Sorted Lists 41.2% Easy C++ / Python
 √ 20 Valid Parentheses 34.0% Easy C++ / Python
 √ 19 Remove Nth Node From End of List 34.0% Medium C++ / Python
 √ 18 4Sum 27.5% Medium C++ / Java / Python
 √ 17 Letter Combinations of a Phone Number 36.5% Medium C++ / Python
 √ 16 3Sum Closest 31.7% Medium C++ / Python
 √ 15 3Sum 21.8% Medium C++ / Java / Python
 √ 14 Longest Common Prefix 31.6% Easy
 √ 13 Roman to Integer 48.1% Easy
 √ 12 Integer to Roman 46.2% Medium
 √ 11 Container With Most Water 37.1% Medium C++ / Java / Python
 √ 10 Regular Expression Matching 24.3% Hard
 √ 9 Palindrome Number 35.8% Easy C++ / Python
 √ 8 String to Integer (atoi) 14.1% Medium C++ / Python
 √ 7 Reverse Integer 24.4% Easy C++ / Java / Python
 √ 6 ZigZag Conversion 27.3% Medium C++ / Java
 √ 5 Longest Palindromic Substring 25.3% Medium C++ / Java / Python
 √ 4 Median of Two Sorted Arrays 23.1% Hard C++ / Python
 √ 3 Longest Substring Without Repeating Characters 24.7% Medium
 √ 2 Add Two Numbers 28.6% Medium C++ / Java / Python
 √ 1 Two Sum 38.0% Easy C++ / Java / Python

听说长得好看的已经打赏了

Leave a Reply

Your email address will not be published. Required fields are marked *

23 thoughts on “Leetcode 算法题解

  1. 博主好! 最近也在刷leetcode!
    今天看了一道 shortest palindrome 还是不太明白怎么用KMP的!
    想问一下具体的步骤哇!

  2. 博主威武,

    麻烦博主有空发一下Majority Element II的题解吧。那题不太好理解为什么那个所谓的voting algorithm works。

    ShadowGiraffe