Leetcode 算法题解

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

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

注:Acceptance、difficulty的数据更新至2017.10.3.

相比之前(有的是对比2015年12月的,哈哈哈), 下面这些题的难度发送了变化:

1 Two Sum | Medium -> Easy
6 ZigZag Conversion | Easy -> Medium
8 String to Integer (atoi) | Easy -> Medium
19 Remove Nth Node From End of List | Easy -> Medium
33 Search in Rotated Sorted Array | Hard -> Medium
35 Search Insert Position | Medium -> Easy
36 Valid Sudoku | Easy -> Medium
53 Maximum Subarray | Medium -> Easy
56 Merge Intervals | Hard -> Medium
69 Sqrt(x) | Medium -> Easy
102 Binary Tree Level Order Traversal | Easy -> Medium
108 Convert Sorted Array to Binary Search Tree | Medium -> Easy
117 Populating Next Right Pointers in Each Node II | Hard -> Medium
121 Best Time to Buy and Sell Stock | Medium -> Easy
122 Best Time to Buy and Sell Stock II | Medium -> Easy
136 Single Number | Medium -> Easy
138 Copy List with Random Pointer | Hard -> Medium
141 Linked List Cycle | Medium -> Easy
165 Compare Version Numbers | Easy -> Medium
223 Rectangle Area | Easy -> Medium
224 Basic Calculator | Medium -> Hard
228 Summary Ranges | Easy -> Medium
233 Number of Digit One | Medium -> Hard
268 Missing Number | Medium -> Easy
273 Integer to English Words | Medium -> Hard
287 Find the Duplicate Number | Hard -> Medium
297 Serialize and Deserialize Binary Tree | Medium -> Hard
299 Bulls and Cows | Easy -> Medium
316 Remove Duplicate Letters | Medium -> Hard
328 Odd Even Linked List | Easy -> Medium
329 Longest Increasing Path in a Matrix | Medium -> Hard
330 Patching Array | Medium -> Hard
335 Self Crossing | Medium -> Hard
355 Design Twitter | Hard -> Medium
367 Valid Perfect Square | Medium -> Easy
381 Insert Delete GetRandom O(1) – Duplicates allowed | Medium -> Hard
396 Rotate Function | Easy -> Medium
397 Integer Replacement | Easy -> Medium

 

下面是解题报告~:

# Title Acceptance Difficulty Language
 √ 699 Falling Squares 35.3% Hard C++ / Python
 √ 698 Partition to K Equal Sum Subsets 34.7% Medium Java
 √ 697 Degree of an Array 49.2% Easy Python
 √ 696 Count Binary Substrings 51.2% Easy Python
 √ 695 Max Area of Island 53.4% Easy Python
 √ 694 Number of Distinct Islands 43.4% Medium Python
 √ 693 Binary Number with Alternating Bits 53.9% Easy Python
 √ 692 Top K Frequent Words 41.7% Medium
 √ 691 Stickers to Spell Word 31.7% Hard Python
 √ 690 Employee Importance 55.6% Easy
 √ 689 Maximum Sum of 3 Non-Overlapping Subarrays 42.8% Hard Python
 √ 688 Knight Probability in Chessboard 38.2% Medium Python
 √ 687 Longest Univalue Path 32.4% Easy Python
 √ 686 Repeated String Match 30.5% Easy Python
 √ 685 Redundant Connection II 29.1% Hard
 √ 684 Redundant Connection 35.8% Medium
 √ 683 K Empty Slots 37.2% Hard
 √ 682 Baseball Game 59.0% Easy
 √ 681 Next Closest Time 42.9% Medium
 √ 680 Valid Palindrome II 31.9% Easy
 √ 679 24 Game 38.5% Hard
 √ 678 Valid Parenthesis String 28.6% Medium
 √ 677 Map Sum Pairs 53.0% Medium
 √ 676 Implement Magic Dictionary 49.9% Medium
 √ 675 Cut Off Trees for Golf Event 27.1% Hard
 √ 674 Longest Continuous Increasing Subsequence 43.0% Easy
 √ 673 Number of Longest Increasing Subsequence 30.9% Medium
 √ 672 Bulb Switcher II 48.1% Medium
 √ 671 Second Minimum Node In a Binary Tree 42.0% Easy
 √ 670 Maximum Swap 38.3% Medium
 √ 669 Trim a Binary Search Tree 58.3% Easy
 √ 668 Kth Smallest Number in Multiplication Table 37.0% Hard
 √ 667 Beautiful Arrangement II 51.8% Medium
 √ 665 Non-decreasing Array 21.3% Easy
 √ 664 Strange Printer 31.3% Hard
 √ 663 Equal Tree Partition 36.6% Medium
 √ 662 Maximum Width of Binary Tree 37.6% Medium
 √ 661 Image Smoother 45.8% Easy
 √ 660 Remove 9 47.0% Hard
 √ 659 Split Array into Consecutive Subsequences 35.6% Medium
 √ 658 Find K Closest Elements 35.7% Medium
 √ 657 Judge Route Circle 68.5% Easy
 √ 655 Print Binary Tree 50.5% Medium
 √ 654 Maximum Binary Tree 70.2% Medium
 √ 653 Two Sum IV – Input is a BST 50.7% Easy
 √ 652 Find Duplicate Subtrees 34.9% Medium
 √ 650 2 Keys Keyboard 44.1% Medium
 √ 649 Dota2 Senate 35.8% Medium
 √ 648 Replace Words 47.7% Medium
 √ 647 Palindromic Substrings 55.8% Medium
 √ 646 Maximum Length of Pair Chain 47.7% Medium
 √ 645 Set Mismatch 40.3% Easy
 √ 643 Maximum Average Subarray I 37.7% Easy
 √ 640 Solve the Equation 39.1% Medium
 √ 639 Decode Ways II 23.6% Hard
 √ 638 Shopping Offers 42.9% Medium
 √ 637 Average of Levels in Binary Tree 55.8% Easy
 √ 636 Exclusive Time of Functions 43.0% Medium
 √ 633 Sum of Square Numbers 32.2% Easy
 √ 632 Smallest Range 42.4% Hard
 √ 630 Course Schedule III 27.5% Hard
 √ 629 K Inverse Pairs Array 26.7% Hard
 √ 628 Maximum Product of Three Numbers 45.0% Easy
 √ 623 Add One Row to Tree 46.7% Medium
 √ 621 Task Scheduler 42.2% Medium
 √ 617 Merge Two Binary Trees 68.0% Easy
 √ 611 Valid Triangle Number 41.7% Medium
 √ 609 Find Duplicate File in System 52.5% Medium
 √ 606 Construct String from Binary Tree 49.8% Easy
 √ 605 Can Place Flowers 30.0% Easy
 √ 600 Non-negative Integers without Consecutive Ones 30.4% Hard
 √ 599 Minimum Index Sum of Two Lists 46.3% Easy
 √ 598 Range Addition II 48.2% Easy
 √ 594 Longest Harmonious Subsequence 41.1% Easy
 √ 593 Valid Square 40.0% Medium
 √ 592 Fraction Addition and Subtraction 46.4% Medium
 √ 591 Tag Validator 29.6% Hard
 √ 587 Erect the Fence 32.4% Hard
 √ 583 Delete Operation for Two Strings 44.0% Medium
 √ 582 Kill Process 49.5% Medium
 √ 581 Shortest Unsorted Continuous Subarray 29.5% Easy
 √ 576 Out of Boundary Paths 30.9% Medium
 √ 575 Distribute Candies 58.7% Easy
 √ 572 Subtree of Another Tree 40.8% Easy
 √ 567 Permutation in String 36.7% Medium
 √ 566 Reshape the Matrix 58.5% Easy
 √ 564 Find the Closest Palindrome 17.3% Hard
 √ 563 Binary Tree Tilt 47.1% Easy
 √ 561 Array Partition I 66.7% Easy
 √ 560 Subarray Sum Equals K 40.2% Medium
 √ 557 Reverse Words in a String III 59.5% Easy
 √ 556 Next Greater Element III 29.0% Medium
 √ 554 Brick Wall 45.7% Medium
 √ 553 Optimal Division 55.1% Medium
 √ 552 Student Attendance Record II 31.4% Hard
 √ 551 Student Attendance Record I 44.0% Easy
 √ 547 Friend Circles 49.2% Medium
 √ 546 Remove Boxes 34.0% Hard
 √ 544 Output Contest Matches 71.0% Medium Python
 √ 543 Diameter of Binary Tree 44.4% Easy Python
 √ 542 01 Matrix 33.3% Medium Python
 √ 541 Reverse String II 43.7% Easy
 √ 540 Single Element in a Sorted Array 55.7% Medium
 √ 539 Minimum Time Difference 45.8% Medium
 √ 538 Convert BST to Greater Tree 49.4% Easy Python
 √ 537 Complex Number Multiplication 64.0% Medium
 √ 535 Encode and Decode TinyURL 74.2% Medium
 √ 532 K-diff Pairs in an Array 28.2% Easy
 √ 530 Minimum Absolute Difference in BST 47.3% Easy
 √ 529 Minesweeper 49.5% Medium
 √ 526 Beautiful Arrangement 54.5% Medium
 √ 525 Contiguous Array 40.4% Medium
 √ 524 Longest Word in Dictionary through Deleting 42.9% Medium
 √ 523 Continuous Subarray Sum 23.1% Medium
 √ 522 Longest Uncommon Subsequence II 31.8% Medium
 √ 521 Longest Uncommon Subsequence I 55.7% Easy
 √ 520 Detect Capital 51.9% Easy
 √ 517 Super Washing Machines 36.5% Hard
 √ 516 Longest Palindromic Subsequence 42.6% Medium
 √ 515 Find Largest Value in Each Tree Row 55.0% Medium
 √ 514 Freedom Trail 39.2% Hard
 √ 513 Find Bottom Left Tree Value 56.1% Medium
 √ 508 Most Frequent Subtree Sum 52.3% Medium
 √ 507 Perfect Number 33.7% Easy
 √ 506 Relative Ranks 46.5% Easy
 √ 504 Base 7 44.2% Easy
 √ 503 Next Greater Element II 47.1% Medium
 √ 502 IPO 36.6% Hard
 √ 501 Find Mode in Binary Search Tree 37.7% Easy
 √ 500 Keyboard Row 59.7% Easy
 √ 498 Diagonal Traverse 45.9% Medium
 √ 496 Next Greater Element I 56.7% Easy
 √ 495 Teemo Attacking 51.5% Medium
 √ 494 Target Sum 43.4% Medium
 √ 493 Reverse Pairs 20.6% Hard
 √ 492 Construct the Rectangle 48.5% Easy
 √ 491 Increasing Subsequences 38.8% Medium
 √ 488 Zuma Game 37.5% Hard
 √ 486 Predict the Winner 45.1% Medium
 √ 485 Max Consecutive Ones 54.0% Easy
 √ 483 Smallest Good Base 33.3% Hard
 √ 482 License Key Formatting 41.6% Medium
 √ 481 Magical String 45.4% Medium
 √ 480 Sliding Window Median 31.2% Hard
 √ 479 Largest Palindrome Product 23.7% Easy
 √ 477 Total Hamming Distance 47.4% Medium
 √ 476 Number Complement 60.9% Easy
 √ 475 Heaters 29.6% Easy
 √ 474 Ones and Zeroes 38.9% Medium
 √ 473 Matchsticks to Square 35.4% Medium
 √ 472 Concatenated Words 30.4% Hard
 √ 468 Validate IP Address 20.8% Medium
 √ 467 Unique Substrings in Wraparound String 32.9% Medium
 √ 466 Count The Repetitions 28.0% Hard
 √ 464 Can I Win 25.0% Medium
 √ 463 Island Perimeter 57.3% Easy
 √ 462 Minimum Moves to Equal Array Elements II 51.8% Medium
 √ 461 Hamming Distance 69.9% Easy
 √ 460 LFU Cache 24.3% Hard
 √ 459 Repeated Substring Pattern 38.1% Easy
 √ 456 132 Pattern 28.8% Medium
 √ 455 Assign Cookies 47.1% Easy
 √ 454 4Sum II 47.1% Medium
 √ 453 Minimum Moves to Equal Array Elements 47.5% Easy
 √ 452 Minimum Number of Arrows to Burst Balloons 44.2% Medium
 √ 451 Sort Characters By Frequency 51.1% Medium
 √ 450 Delete Node in a BST 37.1% Medium
 √ 449 Serialize and Deserialize BST 42.5% Medium C++ / Java / Python
 √ 448 Find All Numbers Disappeared in an Array 51.2% Easy
 √ 447 Number of Boomerangs 45.4% Easy
 √ 446 Arithmetic Slices II – Subsequence 27.1% Hard
 √ 445 Add Two Numbers II 46.0% Medium
 √ 442 Find All Duplicates in an Array 56.1% Medium
 √ 441 Arranging Coins 36.3% Easy
 √ 440 K-th Smallest in Lexicographical Order 25.3% Hard
 √ 438 Find All Anagrams in a String 33.8% Easy
 √ 437 Path Sum III 39.9% Easy
 √ 436 Find Right Interval 41.4% Medium
 √ 435 Non-overlapping Intervals 41.5% Medium
 √ 434 Number of Segments in a String 36.6% Easy
 √ 432 All O`one Data Structure 28.2% Hard C++ / Java / Python
 √ 424 Longest Repeating Character Replacement 42.6% Medium
 √ 423 Reconstruct Original Digits from English 44.5% Medium
 √ 421 Maximum XOR of Two Numbers in an Array 46.5% Medium
 √ 420 Strong Password Checker 20.7% Hard
 √ 419 Battleships in a Board 62.0% Medium
 √ 417 Pacific Atlantic Water Flow 33.8% Medium
 √ 416 Partition Equal Subset Sum 39.3% Medium
 √ 415 Add Strings 41.5% Easy
 √ 414 Third Maximum Number 27.9% Easy
 √ 413 Arithmetic Slices 54.6% Medium
 √ 412 Fizz Buzz 58.5% Easy
 √ 410 Split Array Largest Sum 38.2% Hard
 √ 409 Longest Palindrome 45.4% Easy
 √ 407 Trapping Rain Water II 37.3% Hard
 √ 406 Queue Reconstruction by Height 55.9% Medium
 √ 405 Convert a Number to Hexadecimal 41.1% Easy
 √ 404 Sum of Left Leaves 47.2% Easy
 √ 403 Frog Jump 32.4% Hard Python
 √ 402 Remove K Digits 26.1% Medium Python
 √ 401 Binary Watch 44.9% Easy Python
 √ 400 Nth Digit 30.0% Easy Python
 √ 399 Evaluate Division 41.2% Medium Python
 √ 398 Random Pick Index 43.6% Medium Python
 √ 397 Integer Replacement 30.2% Medium Python
 √ 396 Rotate Function 33.3% Medium Python
 √ 395 Longest Substring with At Least K Repeating Characters 35.8% Medium C++ / Python
 √ 394 Decode String 41.5% Medium Python
 √ 393 UTF-8 Validation 34.7% Medium Python
 √ 392 Is Subsequence 44.6% Medium Python
 √ 391 Perfect Rectangle 26.7% Hard Python
 √ 390 Elimination Game 42.2% Medium Python
 √ 389 Find the Difference 50.8% Easy Python
 √ 388 Longest Absolute File Path 36.8% Medium Python
 √ 387 First Unique Character in a String 47.0% Easy Python
 √ 386 Lexicographical Numbers 41.6% Medium Python
 √ 385 Mini Parser 30.6% Medium Python
 √ 384 Shuffle an Array 46.9% Medium C++ / Java / Python
 √ 383 Ransom Note 47.4% Easy C++ / Java / Python
 √ 382 Linked List Random Node 47.0% Medium C++ / Java / Python
 √ 381 Insert Delete GetRandom O(1) – Duplicates allowed 29.0% Hard C++ / Python
 √ 380 Insert Delete GetRandom O(1) 39.3% Medium Python
 √ 378 Kth Smallest Element in a Sorted Matrix 45.0% Medium C++ / Java / Python
 √ 377 Combination Sum IV 42.2% Medium C++ / Java / Python
 √ 376 Wiggle Subsequence 35.9% Medium C++ / Java / Python
 √ 375 Guess Number Higher or Lower II 35.8% Medium C++ / Java / Python
 √ 374 Guess Number Higher or Lower 35.7% Easy C++ / Java / Python
 √ 373 Find K Pairs with Smallest Sums 30.8% Medium C++
 √ 372 Super Pow 34.5% Medium C++ / Java / Python
 √ 371 Sum of Two Integers 51.2% Easy C++ / Java / Python
 √ 368 Largest Divisible Subset 33.7% Medium C++ / Java / Python
 √ 367 Valid Perfect Square 38.4% Easy C++ / Java / Python
 √ 365 Water and Jug Problem 27.7% Medium C++ / Java / Python
 √ 363 Max Sum of Rectangle No Larger Than K 33.3% Hard C++
 √ 357 Count Numbers with Unique Digits 46.1% Medium C++ / Java / Python
 √ 355 Design Twitter 25.6% Medium Python
 √ 354 Russian Doll Envelopes 32.3% Hard C++ / Python
 √ 352 Data Stream as Disjoint Intervals 40.3% Hard Java
 √ 350 Intersection of Two Arrays II 44.7% Easy Python
 √ 349 Intersection of Two Arrays 47.4% Easy C++ / Java / Python
 √ 347 Top K Frequent Elements 48.5% Medium C++ / Python
 √ 345 Reverse Vowels of a String 38.6% Easy C++
 √ 344 Reverse String 59.5% Easy C++ / Python
 √ 343 Integer Break 46.1% Medium Python
 √ 342 Power of Four 38.7% Easy C++ / Java / Python
 √ 341 Flatten Nested List Iterator 42.0% Medium
 √ 338 Counting Bits 61.6% Medium C++ / Java / Python
 √ 337 House Robber III 43.9% Medium C++ / Java / Python
 √ 336 Palindrome Pairs 26.4% Hard Python
 √ 335 Self Crossing 25.6% Hard C++ / Java / Python
 √ 334 Increasing Triplet Subsequence 39.6% Medium C++ / Java / Python
 √ 332 Reconstruct Itinerary 29.4% Medium C++ / Python
 √ 331 Verify Preorder Serialization of a Binary Tree 36.5% Medium Java / Python
 √ 330 Patching Array 32.2% Hard C++ / Java / Python
 √ 329 Longest Increasing Path in a Matrix 36.7% Hard C++ / Java / Python
 √ 328 Odd Even Linked List 43.9% Medium C++ / Java / Python
 √ 327 Count of Range Sum 30.0% Hard C++ / Python
 √ 326 Power of Three 40.4% Easy C++ / Java / Python
 √ 324 Wiggle Sort II 26.1% Medium Java / Python
 √ 322 Coin Change 26.7% Medium C++ / Java / Python
 √ 321 Create Maximum Number 24.6% Hard C++ / Java / Python
 √ 319 Bulb Switcher 42.7% Medium C++ / Java / Python
 √ 318 Maximum Product of Word Lengths 44.7% Medium C++ / Java / Python
 √ 316 Remove Duplicate Letters 29.8% Hard Python
 √ 315 Count of Smaller Numbers After Self 34.7% Hard
 √ 313 Super Ugly Number 37.9% Medium C++ / Java / Python
 √ 312 Burst Balloons 43.0% Hard
 √ 310 Minimum Height Trees 28.8% Medium
 √ 309 Best Time to Buy and Sell Stock with Cooldown 41.1% Medium
 √ 307 Range Sum Query – Mutable 21.1% Medium
 √ 306 Additive Number 27.6% Medium
 √ 304 Range Sum Query 2D – Immutable 25.8% Medium
 √ 303 Range Sum Query – Immutable 30.4% Easy
 √ 301 Remove Invalid Parentheses 35.3% Hard
 √ 300 Longest Increasing Subsequence 38.6% Medium
 √ 299 Bulls and Cows 35.2% Medium
 √ 297 Serialize and Deserialize Binary Tree 33.8% Hard C++ / Java / Python
 √ 295 Find Median from Data Stream 27.5% Hard
 √ 292 Nim Game 55.2% Easy
 √ 290 Word Pattern 33.1% Easy
 √ 289 Game of Life 37.0% Medium
 √ 287 Find the Duplicate Number 43.7% Medium
 √ 284 Peeking Iterator 35.5% Medium
 √ 283 Move Zeroes 50.4% Easy
 √ 282 Expression Add Operators 30.0% Hard
 √ 279 Perfect Squares 37.3% Medium
 √ 278 First Bad Version 25.6% Easy
 √ 275 H-Index II 34.6% Medium Python
 √ 274 H-Index 33.4% Medium C++ / Python
 √ 273 Integer to English Words 22.3% Hard
 √ 268 Missing Number 44.3% Easy C++ / Python
 √ 264 Ugly Number II 32.9% Medium C++ / Java / Python
 √ 263 Ugly Number 39.4% Easy C++ / Java / Python
 √ 260 Single Number III 52.1% Medium
 √ 258 Add Digits 51.4% Easy C++ / Python
 √ 257 Binary Tree Paths 39.3% Easy
 √ 242 Valid Anagram 46.7% Easy
 √ 241 Different Ways to Add Parentheses 44.7% Medium
 √ 240 Search a 2D Matrix II 38.7% Medium C++ / Java / Python
 √ 239 Sliding Window Maximum 33.5% Hard
 √ 238 Product of Array Except Self 49.6% Medium C++ / Java / Python
 √ 237 Delete Node in a Linked List 46.9% Easy
 √ 236 Lowest Common Ancestor of a Binary Tree 29.9% Medium Python
 √ 235 Lowest Common Ancestor of a Binary Search Tree 39.3% Easy Python
 √ 234 Palindrome Linked List 33.0% Easy
 √ 233 Number of Digit One 28.6% Hard
 √ 232 Implement Queue using Stacks 37.2% Easy
 √ 231 Power of Two 40.3% Easy
 √ 230 Kth Smallest Element in a BST 44.2% Medium
 √ 229 Majority Element II 28.7% Medium
 √ 228 Summary Ranges 30.5% Medium
 √ 227 Basic Calculator II 29.4% Medium
 √ 226 Invert Binary Tree 52.3% Easy
 √ 225 Implement Stack using Queues 33.3% Easy
 √ 224 Basic Calculator 27.5% Hard
 √ 223 Rectangle Area 33.2% Medium
 √ 222 Count Complete Tree Nodes 27.6% Medium
 √ 221 Maximal Square 29.4% Medium
 √ 220 Contains Duplicate III 19.0% Medium C++ / Java / Python
 √ 219 Contains Duplicate II 32.6% Easy C++ / Java / Python
 √ 218 The Skyline Problem 27.8% Hard
 √ 217 Contains Duplicate 46.1% Easy C++ / Java / Python
 √ 216 Combination Sum III 45.7% Medium
 √ 215 Kth Largest Element in an Array 39.6% Medium
 √ 214 Shortest Palindrome 24.6% Hard
 √ 213 House Robber II 34.2% Medium
 √ 212 Word Search II 23.7% Hard
 √ 211 Add and Search Word – Data structure design 23.6% Medium
 √ 210 Course Schedule II 28.7% Medium
 √ 209 Minimum Size Subarray Sum 31.2% Medium
 √ 208 Implement Trie (Prefix Tree) 29.1% Medium
 √ 207 Course Schedule 32.6% Medium
 √ 206 Reverse Linked List 45.9% Easy
 √ 205 Isomorphic Strings 34.1% Easy
 √ 204 Count Primes 26.6% Easy C++ / Java / Python
 √ 203 Remove Linked List Elements 32.7% Easy
 √ 202 Happy Number 40.9% Easy
 √ 201 Bitwise AND of Numbers Range 34.2% Medium
 √ 200 Number of Islands 35.2% Medium
 √ 199 Binary Tree Right Side View 41.5% Medium
 √ 198 House Robber 39.3% Easy
 √ 191 Number of 1 Bits 39.8% Easy
 √ 190 Reverse Bits 29.5% Easy
 √ 189 Rotate Array 24.9% Easy
 √ 188 Best Time to Buy and Sell Stock IV 24.4% Hard
 √ 187 Repeated DNA Sequences 32.0% Medium
 √ 179 Largest Number 22.9% Medium C++ / Java / Python
 √ 174 Dungeon Game 23.9% Hard
 √ 173 Binary Search Tree Iterator 42.0% Medium
 √ 172 Factorial Trailing Zeroes 36.3% Easy
 √ 171 Excel Sheet Column Number 47.6% Easy
 √ 169 Majority Element 47.0% Easy
 √ 168 Excel Sheet Column Title 26.5% Easy
 √ 167 Two Sum II – Input array is sorted 47.2% Easy
 √ 166 Fraction to Recurring Decimal 17.7% Medium
 √ 165 Compare Version Numbers 20.3% Medium
 √ 164 Maximum Gap 29.7% Hard
 √ 162 Find Peak Element 37.9% Medium
 √ 160 Intersection of Two Linked Lists 30.7% Easy C / C++ / Java / Python
 √ 155 Min Stack 29.3% Easy
 √ 154 Find Minimum in Rotated Sorted Array II 37.4% Hard
 √ 153 Find Minimum in Rotated Sorted Array 40.2% Medium
 √ 152 Maximum Product Subarray 26.0% Medium
 √ 151 Reverse Words in a String 15.7% Medium
 √ 150 Evaluate Reverse Polish Notation 27.5% Medium
 √ 149 Max Points on a Line 15.3% Hard
 √ 148 Sort List 29.1% Medium
 √ 147 Insertion Sort List 33.3% Medium
 √ 146 LRU Cache 18.4% Hard
 √ 145 Binary Tree Postorder Traversal 40.6% Hard
 √ 144 Binary Tree Preorder Traversal 45.5% Medium
 √ 143 Reorder List 25.9% Medium
 √ 142 Linked List Cycle II 30.9% Medium C++ / Java / Python
 √ 141 Linked List Cycle 35.3% Easy C / C++ / Java / Python
 √ 140 Word Break II 23.6% Hard
 √ 139 Word Break 30.4% Medium
 √ 138 Copy List with Random Pointer 26.1% Medium
 √ 137 Single Number II 41.9% Medium
 √ 136 Single Number 54.8% Easy
 √ 135 Candy 24.9% Hard
 √ 134 Gas Station 29.5% Medium
 √ 133 Clone Graph 25.1% Medium
 √ 132 Palindrome Partitioning II 24.4% Hard C++ / Java / Python
 √ 131 Palindrome Partitioning 34.0% Medium
 √ 130 Surrounded Regions 18.7% Medium
 √ 129 Sum Root to Leaf Numbers 37.0% Medium
 √ 128 Longest Consecutive Sequence 37.3% Hard
 √ 127 Word Ladder 19.5% Medium
 √ 126 Word Ladder II 14.4% Hard
 √ 125 Valid Palindrome 26.5% Easy
 √ 124 Binary Tree Maximum Path Sum 26.4% Hard
 √ 123 Best Time to Buy and Sell Stock III 29.6% Hard
 √ 122 Best Time to Buy and Sell Stock II 47.4% Easy
 √ 121 Best Time to Buy and Sell Stock 41.7% Easy
 √ 120 Triangle 34.1% Medium
 √ 119 Pascal’s Triangle II 37.3% Easy
 √ 118 Pascal’s Triangle 39.0% Easy
 √ 117 Populating Next Right Pointers in Each Node II 33.8% Medium
 √ 116 Populating Next Right Pointers in Each Node 36.9% Medium
 √ 115 Distinct Subsequences 31.7% Hard
 √ 114 Flatten Binary Tree to Linked List 35.5% Medium
 √ 113 Path Sum II 34.3% Medium
 √ 112 Path Sum 34.2% Easy
 √ 111 Minimum Depth of Binary Tree 33.3% Easy
 √ 110 Balanced Binary Tree 37.8% Easy
 √ 109 Convert Sorted List to Binary Search Tree 34.4% Medium C++ / Java / Python
 √ 108 Convert Sorted Array to Binary Search Tree 42.5% Easy C++ / Java / Python
 √ 107 Binary Tree Level Order Traversal II 40.8% Easy
 √ 106 Construct Binary Tree from Inorder and Postorder Traversal 32.4% Medium
 √ 105 Construct Binary Tree from Preorder and Inorder Traversal 32.6% Medium
 √ 104 Maximum Depth of Binary Tree 53.1% Easy
 √ 103 Binary Tree Zigzag Level Order Traversal 35.2% Medium
 √ 102 Binary Tree Level Order Traversal 40.6% Medium
 √ 101 Symmetric Tree 39.2% Easy
 √ 100 Same Tree 46.8% Easy
 √ 99 Recover Binary Search Tree 30.2% Hard
 √ 98 Validate Binary Search Tree 23.6% Medium
 √ 97 Interleaving String 24.8% Hard
 √ 96 Unique Binary Search Trees 41.3% Medium
 √ 95 Unique Binary Search Trees II 31.7% Medium
 √ 94 Binary Tree Inorder Traversal 47.4% Medium
 √ 93 Restore IP Addresses 27.7% Medium
 √ 92 Reverse Linked List II 30.9% Medium
 √ 91 Decode Ways 19.9% Medium
 √ 90 Subsets II 36.8% Medium
 √ 89 Gray Code 41.6% Medium
 √ 88 Merge Sorted Array 32.1% Easy
 √ 87 Scramble String 29.4% Hard
 √ 86 Partition List 32.9% Medium
 √ 85 Maximal Rectangle 28.5% Hard
 √ 84 Largest Rectangle in Histogram 27.0% Hard
 √ 83 Remove Duplicates from Sorted List 40.0% Easy
 √ 82 Remove Duplicates from Sorted List II 29.6% Medium
 √ 81 Search in Rotated Sorted Array II 32.7% Medium
 √ 80 Remove Duplicates from Sorted Array II 36.3% Medium
 √ 79 Word Search 27.2% Medium
 √ 78 Subsets 41.8% Medium
 √ 77 Combinations 40.1% Medium
 √ 76 Minimum Window Substring 25.9% Hard
 √ 75 Sort Colors 38.3% Medium
 √ 74 Search a 2D Matrix 34.9% Medium
 √ 73 Set Matrix Zeroes 36.1% Medium
 √ 72 Edit Distance 32.0% Hard
 √ 71 Simplify Path 25.7% Medium
 √ 70 Climbing Stairs 40.3% Easy
 √ 69 Sqrt(x) 28.0% Easy
 √ 68 Text Justification 19.4% Hard C++ / Python
 √ 67 Add Binary 32.9% Easy
 √ 66 Plus One 38.9% Easy
 √ 65 Valid Number 12.8% Hard
 √ 64 Minimum Path Sum 38.9% Medium
 √ 63 Unique Paths II 31.9% Medium
 √ 62 Unique Paths 41.7% Medium
 √ 61 Rotate List 24.3% Medium
 √ 60 Permutation Sequence 28.9% Medium
 √ 59 Spiral Matrix II 40.1% Medium
 √ 58 Length of Last Word 31.9% Easy
 √ 57 Insert Interval 28.1% Hard
 √ 56 Merge Intervals 30.7% Medium
 √ 55 Jump Game 29.5% Medium
 √ 54 Spiral Matrix 26.4% Medium
 √ 53 Maximum Subarray 39.8% Easy
 √ 52 N-Queens II 45.5% Hard
 √ 51 N-Queens 31.7% Hard
 √ 50 Pow(x, n) 26.1% Medium
 √ 49 Group Anagrams 35.9% Medium
 √ 48 Rotate Image 39.5% Medium
 √ 47 Permutations II 33.4% Medium
 √ 46 Permutations 44.8% Medium
 √ 45 Jump Game II 26.2% Hard
 √ 44 Wildcard Matching 20.4% Hard
 √ 43 Multiply Strings 27.4% Medium
 √ 42 Trapping Rain Water 37.0% Hard
 √ 41 First Missing Positive 25.6% Hard
 √ 40 Combination Sum II 34.4% Medium C++ / Java / Python
 √ 39 Combination Sum 39.5% Medium C++ / Java / Python
 √ 38 Count and Say 35.3% Easy
 √ 37 Sudoku Solver 30.7% Hard
 √ 36 Valid Sudoku 36.3% Medium
 √ 35 Search Insert Position 39.8% Easy
 √ 34 Search for a Range 31.4% Medium
 √ 33 Search in Rotated Sorted Array 32.1% Medium
 √ 32 Longest Valid Parentheses 23.1% Hard
 √ 31 Next Permutation 28.8% Medium
 √ 30 Substring with Concatenation of All Words 22.0% Hard
 √ 29 Divide Two Integers 15.9% Medium
 √ 28 Implement strStr() 28.4% Easy
 √ 27 Remove Element 39.6% Easy
 √ 26 Remove Duplicates from Sorted Array 35.4% Easy
 √ 25 Reverse Nodes in k-Group 31.0% Hard
 √ 24 Swap Nodes in Pairs 38.6% Medium
 √ 23 Merge k Sorted Lists 27.6% Hard
 √ 22 Generate Parentheses 45.9% Medium
 √ 21 Merge Two Sorted Lists 39.3% Easy
 √ 20 Valid Parentheses 33.6% Easy
 √ 19 Remove Nth Node From End of List 33.8% Medium
 √ 18 4Sum 27.0% Medium
 √ 17 Letter Combinations of a Phone Number 35.1% Medium
 √ 16 3Sum Closest 31.3% Medium
 √ 15 3Sum 21.8% Medium
 √ 14 Longest Common Prefix 31.5% Easy
 √ 13 Roman to Integer 46.4% Easy
 √ 12 Integer to Roman 45.3% Medium
 √ 11 Container With Most Water 36.8% Medium
 √ 10 Regular Expression Matching 24.2% Hard
 √ 9 Palindrome Number 35.5% Easy
 √ 8 String to Integer (atoi) 14.0% Medium
 √ 7 Reverse Integer 24.5% Easy
 √ 6 ZigZag Conversion 26.9% Medium
 √ 5 Longest Palindromic Substring 25.3% Medium
 √ 4 Median of Two Sorted Arrays 22.1% Hard
 √ 3 Longest Substring Without Repeating Characters 24.4% Medium
 √ 2 Add Two Numbers 28.0% Medium
 √ 1 Two Sum 35.6% Easy

听说帅的人已经打赏了

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