Leetcode 题解

  • 博客地址:http://www.liuchuo.net/
  • 转载过来,方便自己刷题记录,感谢上面的楼主
    • 博客地址:http://www.liuchuo.net/
    ID Title Difficulty Java Python mycode C++
    001 Two Sum Easy Java Python   C++
    002 Add Two Numbers Medium Java Python   C++
    003 Longest Substring Without Repeating Characters Medium Java Python   C++
    004 Median of Two Sorted Arrays Hard no no   no
    005 Longest Palindromic Substring Medium no no   C++
    006 ZigZag Conversion Easy Java Python   C++
    007 Reverse Integer Easy Java Python   C++
    008 String to Integer (atoi) Easy Java no   C++
    009 Palindrome Number Easy Java Python   C++
    010 Regular Expression Matching Hard Java no   no
    011 Container With Most Water Medium Java no no C++
    012 Integer to Roman Medium Java Python no C++
    013 Roman to Integer Easy Java Python no C++
    014 Longest Common Prefix Easy Java Python no C++
    015 3Sum Medium Java Python Ruby C++
    016 3Sum Closest Medium Java no no C++
    017 Letter Combinations of a Phone Number Medium Java Python no C++
    018 4Sum Medium Java no no C++
    019 Remove Nth Node From End of List Easy Java Python Ruby C++
    020 Valid Parentheses Easy Java no no C++
    021 Merge Two Sorted Lists Easy Java Python Ruby C++
    022 Generate Parentheses Medium Java Python no C++
    023 Merge k Sorted Lists Hard Java Python Ruby no
    024 Swap Nodes in Pairs Easy Java Python no C++
    025 Reverse Nodes in k-Group Hard Java no no no
    026 Remove Duplicates from Sorted Array Easy Java Python no C++
    027 Remove Element Easy Java Python no C++
    028 Implement strStr() Easy Java no no C++
    029 Divide Two Integers Medium Java no no C++
    030 Substring with Concatenation of All Words Hard no no no no
    031 Next Permutation Medium Java Python no C++
    032 Longest Valid Parentheses Hard Java no no no
    033 Search in Rotated Sorted Array Hard Java no no no
    034 Search for a Range Medium Java Python no C++
    035 Search Insert Position Medium Java Python no C++
    036 Valid Sudoku Easy Java no no C++
    037 Sudoku Solver Hard Java no no no
    038 Count and Say Easy Java no no C++
    039 Combination Sum Medium Java Python no C++
    040 Combination Sum II Medium Java no no C++
    041 First Missing Positive Hard Java Python no no
    042 Trapping Rain Water Hard Java no no C++
    043 Multiply Strings Medium Java Python no no
    044 Wildcard Matching Hard no no no no
    045 Jump Game II Hard Java no no no
    046 Permutations Medium Java Python no C++
    047 Permutations II Medium Java Python no C++
    048 Rotate Image Medium Java Python no C++
    049 Group Anagrams Medium Java Python no no
    050 Pow(x, n) Medium Java Python no no
    051 N-Queens Hard Java Python no C++
    052 N-Queens II Hard Java Python no C++
    053 Maximum Subarray Medium Java Python no C++
    054 Spiral Matrix Medium Java Python no no
    055 Jump Game Medium Java Python no C++
    056 Merge Intervals Hard Java no no no
    057 Insert Interval Hard Java Python no no
    058 Length of Last Word Easy Java Python no C++
    059 Spiral Matrix II Medium Java Python no C++
    060 Permutation Sequence Medium Java Python no C++
    061 Rotate List Medium Java Python no C++
    062 Unique Paths Medium Java Python no C++
    063 Unique Paths II Medium Java Python no C++
    064 Minimum Path Sum Medium Java Python no C++
    065 Valid Number Hard no no no no
    066 Plus One Easy Java no no C++
    067 Add Binary Easy Java Python no C++
    068 Text Justification Hard Java Python no no
    069 Sqrt(x) Medium Java Python no C++
    070 Climbing Stairs Easy Java Python no C++
    071 Simplify Path Medium no no no C++
    072 Edit Distance Hard Java Python no no
    073 Set Matrix Zeroes Medium Java Python no no
    074 Search a 2D Matrix Medium Java Python no no
    075 Sort Colors Medium Java Python no C++
    076 Minimum Window Substring Hard no no no no
    077 Combinations Medium Java Python no C++
    078 Subsets Medium Java Python no C++
    079 Word Search Medium Java no no no
    080 Remove Duplicates from Sorted Array II Medium Java Python no C++
    081 Search in Rotated Sorted Array II Medium Java no no no
    082 Remove Duplicates from Sorted List II Medium Java Python no C++
    083 Remove Duplicates from Sorted List Easy Java Python no C++
    084 Largest Rectangle in Histogram Hard no no no no
    085 Maximal Rectangle Hard no no no no
    086 Partition List Medium Java Python no no
    087 Scramble String Hard Java Python no no
    088 Merge Sorted Array Easy Java Python no C++
    089 Gray Code Medium Java Python no no
    090 Subsets II Medium Java Python no C++
    091 Decode Ways Medium Java Python no C++
    092 Reverse Linked List II Medium Java no no no
    093 Restore IP Addresses Medium Java Python no C++
    094 Binary Tree Inorder Traversal Medium Java Python Ruby C++
    095 Unique Binary Search Trees II Medium Java no no no
    096 Unique Binary Search Trees Medium Java Python no C++
    097 Interleaving String Hard Java Python no no
    098 Validate Binary Search Tree Medium Java Python Ruby C++
    099 Recover Binary Search Tree Hard no Python no no
    100 Same Tree Easy Java Python Ruby C++
    101 Symmetric Tree Easy Java Python Ruby C++
    102 Binary Tree Level Order Traversal Easy Java Python no C++
    103 Binary Tree Zigzag Level Order Traversal Medium Java Python no C++
    104 Maximum Depth of Binary Tree Easy Java Python Ruby C++
    105 Construct Binary Tree from Preorder and Inorder Traversal Medium Java Python Ruby no
    106 Construct Binary Tree from Inorder and Postorder Traversal Medium Java Python Ruby no
    107 Binary Tree Level Order Traversal II Easy Java Python no C++
    108 Convert Sorted Array to Binary Search Tree Medium Java Python no C++
    109 Convert Sorted List to Binary Search Tree Medium Java Python no C++
    110 Balanced Binary Tree Easy Java Python Ruby C++
    111 Minimum Depth of Binary Tree Easy Java Python Ruby C++
    112 Path Sum Easy Java Python Ruby C++
    113 Path Sum II Medium Java Python no C++
    114 Flatten Binary Tree to Linked List Medium Java Python no no
    115 Distinct Subsequences Hard no no no no
    116 Populating Next Right Pointers in Each Node Medium Java Python no no
    117 Populating Next Right Pointers in Each Node II Hard Java Python no no
    118 Pascal's Triangle Easy Java Python no C++
    119 Pascal's Triangle II Easy Java Python no C++
    120 Triangle Medium Java Python no C++
    121 Best Time to Buy and Sell Stock Easy Java no no C++
    122 Best Time to Buy and Sell Stock II Medium Java no no C++
    123 Best Time to Buy and Sell Stock III Hard Java no no no
    124 Binary Tree Maximum Path Sum Hard Java no no no
    125 Valid Palindrome Easy Java no no C++
    126 Word Ladder II Hard no no no no
    127 Word Ladder Medium Java no no C++
    128 Longest Consecutive Sequence Hard Java no no no
    129 Sum Root to Leaf Numbers Medium Java Python no C++
    130 Surrounded Regions Medium Java no no C++
    131 Palindrome Partitioning Medium Java no no no
    132 Palindrome Partitioning II Hard no no no no
    133 Clone Graph Medium Java Python no no
    134 Gas Station Medium Java Python no C++
    135 Candy Hard Java no no no
    136 Single Number Easy Java Python no C++
    137 Single Number II Medium Java no no C++
    138 Copy List with Random Pointer Hard Java Python no no
    139 Word Break Medium Java no no no
    140 Word Break II Hard Java no no no
    141 Linked List Cycle Easy Java Python no C++
    142 Linked List Cycle II Medium Java Python no C++
    143 Reorder List Medium Java Python no C++
    144 Binary Tree Preorder Traversal Medium Java Python Ruby C++
    145 Binary Tree Postorder Traversal Hard Java Python no C++
    146 LRU Cache Hard Java Python no no
    147 Insertion Sort List Medium Java no no no
    148 Sort List Medium Java Python no no
    149 Max Points on a Line Hard Java no no no
    150 Evaluate Reverse Polish Notation Medium Java no no no
    151 Reverse Words in a String Medium Java no no C++
    152 Maximum Product Subarray Medium Java no no C++
    153 Find Minimum in Rotated Sorted Array Medium Java no no C++
    154 Find Minimum in Rotated Sorted Array II Hard Java no no no
    155 Min Stack Easy Java no no C++
    156 Binary Tree Upside Down Medium Java no no no
    157 Read N Characters Given Read4 Easy no no no no
    158 Read N Characters Given Read4 II - Call multiple times Hard no no no no
    159 Longest Substring with At Most Two Distinct Characters Hard no no no no
    160 Intersection of Two Linked Lists Easy Java Python no C++
    161 One Edit Distance Medium Java no no no
    162 Find Peak Element Medium Java no no C++
    163 Missing Ranges Medium no no no no
    164 Maximum Gap Hard Java no no no
    165 Compare Version Numbers Easy Java Python no C++
    166 Fraction to Recurring Decimal Medium Java no no C++
    167 Two Sum II - Input array is sorted Medium Java no no C++
    168 Excel Sheet Column Title Easy Java Python no C++
    169 Majority Element Easy Java Python no C++
    170 Two Sum III - Data structure design Easy no no no no
    171 Excel Sheet Column Number Easy Java Python no C++
    172 Factorial Trailing Zeroes Easy Java Python no C++
    173 Binary Search Tree Iterator Medium Java no no no
    174 Dungeon Game Hard no no no no
    179 Largest Number Medium Java Python no C++
    186 Reverse Words in a String II Medium no no no no
    187 Repeated DNA Sequences Medium Java no no no
    188 Best Time to Buy and Sell Stock IV Hard no no no no
    189 Rotate Array Easy Java Python no C++
    190 Reverse Bits Easy Java Python no C++
    191 Number of 1 Bits Easy Java Python no C++
    198 House Robber Easy Java Python no C++
    199 Binary Tree Right Side View Medium Java Python no C++
    200 Number of Islands Medium Java Python no no
    201 Bitwise AND of Numbers Range Medium Java no no no
    202 Happy Number Easy Java Python no C++
    203 Remove Linked List Elements Easy Java Python no C++
    204 Count Primes Easy Java no no C++
    205 Isomorphic Strings Easy Java Python no C++
    206 Reverse Linked List Easy Java Python no C++
    207 Course Schedule Medium no no no no
    208 Implement Trie (Prefix Tree) Medium Java no no no
    209 Minimum Size Subarray Sum Medium no no no C++
    210 Course Schedule II Medium no no no no
    211 Add and Search Word - Data structure design Medium no no no no
    212 Word Search II Hard Java no no no
    213 House Robber II Medium Java Python no C++
    214 Shortest Palindrome Hard no no no no
    215 Kth Largest Element in an Array Medium Java Python no C++
    216 Combination Sum III Medium Java Python no C++
    217 Contains Duplicate Easy Java Python no C++
    218 The Skyline Problem Hard no no no no
    219 Contains Duplicate II Easy Java Python no C++
    220 Contains Duplicate III Medium no no no C++
    221 Maximal Square Medium Java no no no
    222 Count Complete Tree Nodes Medium Java Python no C++
    223 Rectangle Area Easy Java Python no C++
    224 Basic Calculator Hard no no no no
    225 Implement Stack using Queues Easy Java no no C++
    226 Invert Binary Tree Easy Java Python Ruby C++
    227 Basic Calculator II Medium no no no no
    228 Summary Ranges Medium Java Python no C++
    229 Majority Element II Medium Java no no no
    230 Kth Smallest Element in a BST Medium Java Python Ruby C++
    231 Power of Two Easy Java Python no C++
    232 Implement Queue using Stacks Easy Java no no C++
    233 Number of Digit One Hard no no no no
    234 Palindrome Linked List Easy Java no no C++
    235 Lowest Common Ancestor of a Binary Search Tree Easy Java Python no C++
    236 Lowest Common Ancestor of a Binary Tree Medium Java Python no no
    237 Delete Node in a Linked List Easy Java Python no C++
    238 Product of Array Except Self Medium Java Python no C++
    239 Sliding Window Maximum Hard Java Python no no
    240 Search a 2D Matrix II Medium Java no no no
    241 Different Ways to Add Parentheses Medium no no no no
    242 Valid Anagram Easy Java Python no C++
    243 Shortest Word Distance Easy no no no no
    244 Shortest Word Distance II Medium no no no no
    245 Shortest Word Distance III Medium no no no no
    246 Strobogrammatic Number Easy no no no no
    247 Strobogrammatic Number II Medium no no no no
    248 Strobogrammatic Number III Hard no no no no
    249 Group Shifted Strings Easy no no no no
    250 Count Univalue Subtrees Medium no no no no
    251 Flatten 2D Vector Medium no no no no
    252 Meeting Rooms Easy no no no no
    253 Meeting Rooms II Medium no no no no
    254 Factor Combinations Medium no no no no
    255 Verify Preorder Sequence in Binary Search Tree Medium no no no no
    256 Paint House Medium no no no no
    257 Binary Tree Paths Easy Java Python no no
    258 Add Digits Easy Java Python no C++
    259 3Sum Smaller Medium no no no no
    260 Single Number III Medium Java Python no C++
    261 Graph Valid Tree Medium no no no no
    263 Ugly Number Easy Java Python no C++
    264 Ugly Number II Medium Java no no no
    265 Paint House II Hard no no no no
    266 Palindrome Permutation Easy no no no no
    267 Palindrome Permutation II Medium no no no no
    268 Missing Number Medium Java Python no C++
    269 Alien Dictionary Hard no no no no
    270 Closest Binary Search Tree Value Easy no no no no
    271 Encode and Decode Strings Medium no no no no
    272 Closest Binary Search Tree Value II Hard no no no no
    273 Integer to English Words Hard Java Python no no
    274 H-Index Medium Java no no no
    275 H-Index II Medium Java no no no
    276 Paint Fence Easy no no no no
    277 Find the Celebrity Medium no no no no
    278 First Bad Version Easy Java Python no C++
    279 Perfect Squares Medium Java no no C++
    280 Wiggle Sort Medium no no no no
    281 Zigzag Iterator Medium no no no no
    282 Expression Add Operators Hard no no no no
    283 Move Zeroes Easy Java Python no C++
    284 Peeking Iterator Medium Java no no no
    285 Inorder Successor in BST Medium no no no no
    286 Walls and Gates Medium no no no no
    287 Find the Duplicate Number Hard Java Python no no
    288 Unique Word Abbreviation Easy no no no no
    289 Game of Life Medium Java Python no no
    290 Word Pattern Easy Java Python no C++
    291 Word Pattern II Hard no no no no
    292 Nim Game Easy Java Python no C++
    293 Flip Game Easy no no no no
    294 Flip Game II Medium no no no no
    295 Find Median from Data Stream Hard Java no no no
    296 Best Meeting Point Hard no no no no
    297 Serialize and Deserialize Binary Tree Hard Java no no no
    298 Binary Tree Longest Consecutive Sequence Medium no no no no
    299 Bulls and Cows Easy Java Python no C++
    300 Longest Increasing Subsequence Medium Java no no C++
    301 Remove Invalid Parentheses Hard no no no no
    302 Smallest Rectangle Enclosing Black Pixels Hard no no no no
    303 Range Sum Query - Immutable Easy Java Python no C++
    304 Range Sum Query 2D - Immutable Medium no Python no C++
    305 Number of Islands II Hard no no no no
    306 Additive Number Medium Java Python no no
    307 Range Sum Query - Mutable Medium Java no no C++
    308 Range Sum Query 2D - Mutable Hard no no no no
    309 Best Time to Buy and Sell Stock with Cooldown Medium Java no no no
    310 Minimum Height Trees Medium no no no no
    311 Sparse Matrix Multiplication Medium no no no no
    312 Burst Balloons Hard no no no no
    313 Super Ugly Number Medium no no no no
    314 Binary Tree Vertical Order Traversal Medium no no no no
    315 Count of Smaller Numbers After Self Hard Java Python no no
    316 Remove Duplicate Letters Hard Java no no no
    317 Shortest Distance from All Buildings Hard no no no no
    318 Maximum Product of Word Lengths Medium Java Python no C++
    319 Bulb Switcher Medium Java Python no C++
    320 Generalized Abbreviation Medium no no no no
    321 Create Maximum Number Hard no no no no
    322 Coin Change Medium Java no no no
    323 Number of Connected Components in an Undirected Graph Medium no no no no
    324 Wiggle Sort II Medium no Python no C++
    325 Maximum Size Subarray Sum Equals k Medium no no no no
    326 Power of Three Easy Java Python no C++
    327 Count of Range Sum Hard no no no no
    328 Odd Even Linked List Medium Java Python no C++
    329 Longest Increasing Path in a Matrix Hard Java Python no no
    330 Patching Array Hard no no no C++
    331 Verify Preorder Serialization of a Binary Tree Medium Java Python no no
    332 Reconstruct Itinerary Medium no no no no
    333 Largest BST Subtree Medium no no no no
    334 Increasing Triplet Subsequence Medium Java Python no no
    335 Self Crossing Hard no no no no
    336 Palindrome Pairs Hard no no no no
    337 House Robber III Medium Java Python no no
    338 Counting Bits Medium Java Python no C++
    339 Nested List Weight Sum Easy no no no no
    340 Longest Substring with At Most K Distinct Characters Hard no no no no
    341 Flatten Nested List Iterator Medium Java Python no no
    342 Power of Four Easy Java Python no no
    343 Integer Break Medium Java Python no C++
    344 Reverse String Easy Java Python no C++
    345 Reverse Vowels of a String Easy Java Python no C++
    346 Moving Average from Data Stream Easy no no no no
    347 Top K Frequent Elements Medium Java Python no C++
    348 Design Tic-Tac-Toe Medium no no no no
    349 Intersection of Two Arrays Easy Java no no C++
    350 Intersection of Two Arrays II Easy Java no no C++
    351 Android Unlock Patterns Medium no no no no
    352 Data Stream as Disjoint Intervals Hard Java no no no
    353 Design Snake Game Medium no no no no
    354 Russian Doll Envelopes Hard Java no no no
    355 Design Twitter Medium Java no no no
    356 Line Reflection Medium no no no no
    357 Count Numbers with Unique Digits Medium Java no no C++
    358 Rearrange String k Distance Apart Hard no no no no
    359 Logger Rate Limiter Easy no no no no
    360 Sort Transformed Array Medium no no no no
    361 Bomb Enemy Medium no no no no
    362 Design Hit Counter Medium no no no no
    363 Max Sum of Rectangle No Larger Than K Hard Java no no no
    364 Nested List Weight Sum II Medium no no no no
    365 Water and Jug Problem Medium Java no no C++
    366 Find Leaves of Binary Tree Medium no no no no
    367 Valid Perfect Square Medium Java no no C++
    368 Largest Divisible Subset Medium Java no no no
    369 Plus One Linked List Medium no no no no
    370 Range Addition Medium no no no no
    371 Sum of Two Integers Easy Java no no C++
    372 Super Pow Medium Java no no no
    373 Find K Pairs with Smallest Sums Medium Java no no no
    374 Guess Number Higher or Lower Easy Java no no C++
    375 Guess Number Higher or Lower II Medium Java no no no
    376 Wiggle Subsequence Medium Java no no no
    377 Combination Sum IV Medium Java no no no
    378 Kth Smallest Element in a Sorted Matrix Medium Java no no C++
    379 Design Phone Directory Medium no no no no
    380 Insert Delete GetRandom O(1) Hard Java no no no
    381 Insert Delete GetRandom O(1) - Duplicates allowed Hard Java no no no
    382 Linked List Random Node Medium Java no no C++
    383 Ransom Note Easy Java no no C++
    384 Shuffle an Array Medium Java no no C++
    385 Mini Parser Medium Java no no no
    386 Lexicographical Numbers Medium Java no no no
    387 First Unique Character in a String Easy Java no no C++
    388 Longest Absolute File Path Medium Java no no no
    389 Find the Difference Easy Java no no C++
    390 Elimination Game Medium Java no no no
    391 Perfect Rectangle Hard Java no no no
    392 Is Subsequence Medium Java no no C++
    393 UTF-8 Validation Medium Java no no no
    394 Decode String Medium Java no no no
    395 Longest Substring with At Least K Repeating Characters Medium Java no no no
    396 Rotate Function Easy Java no no C++
    397 Integer Replacement Medium Java no no no
    398 Random Pick Index Medium Java no no C++
    399 Evaluate Division Medium no no no no
    400 Nth Digit Easy Java no no C++
    401 Binary Watch Easy Java no no C++
    402 Remove K Digits Medium Java no no C++
    403 Frog Jump Hard Java no no no
    404 Sum of Left Leaves Easy Java no no C++
    405 Convert a Number to Hexadecimal Easy Java no no C++
    406 Queue Reconstruction by Height Medium Java no no C++
    407 Trapping Rain Water II Hard no no no no
    408 Valid Word Abbreviation Easy no no no no
    409 Longest Palindrome Easy Java no no C++
    410 Split Array Largest Sum Hard no no no no
    411 Minimum Unique Word Abbreviation Hard no no no no
    412 Fizz Buzz Easy no no no C++
    413 Arithmetic Slices Medium no no no C++
    415 Add Strings Easy Java no no C++
    416 Partition Equal Subset Sum Medium Java no no no
    417 Pacific Atlantic Water Flow Medium Java no no no
    418 Sentence Screen Fitting Medium no no no no
    419 Battleships in a Board Medium no no no C++
    423 Reconstruct Original Digits from English Medium no no no C++
    434 Number of Segments in a String Easy no no no C++
    437 Path Sum III Easy no no no C++
    438 Find All Anagrams in a String Easy no no no C++
    441 Arranging Coins Easy no no no C++
    442 Find All Duplicates in an Array Medium no no no C++
    445 Add Two Numbers II Medium no no no C++
    447 Number of Boomerangs Easy no no no C++
    448 Find All Numbers Disappeared in an Array Easy no no no C++
    451 Sort Characters By Frequency Medium no no no C++
    453 Minimum Moves to Equal Array Elements Easy no no no C++
    454 4Sum II Medium no no no C++
    455 Assign Cookies Easy no no no C++
    459 Repeated Substring Pattern Easy no no no C++
    461 Hamming Distance Easy no no no C++
    462 Minimum Moves to Equal Array Elements II Medium no no no C++
    463 Island Perimeter Easy no no no C++
    464 Can I Win Medium no no no C++
    468 Validate IP Address Medium no no no C++
    475 Heaters Easy no no no C++
    476 Number Complement Easy no no no C++
    477 Total Hamming Distance Medium no no no C++
    481 Magical String Medium no no no C++
    482 License Key Formatting Medium no no no C++
    485 Max Consecutive Ones Easy no no no C++
    486 Predict the Winner Medium no no no C++
    491 Increasing Subsequences Medium no no no C++
    492 Construct the Rectangle Medium no no no C++
    494 Target Sum Medium no no no C++
    495 Teemo Attacking Medium no no no C++
    496 Next Greater Element I Easy no no no C++
    498 Diagonal Traverse Medium no no no C++
    500 Keyboard Row Easy no no no C++
    501 Find Mode in Binary Search Tree Medium no no no C++
    503 Next Greater Element II Medium no no no C++
    504 Base 7 Easy no no no C++
    506 Relative Ranks Easy no no no C++
    508 Most Frequent Subtree Sum Medium no no no C++
    513 Find Bottom Left Tree Value Medium no no no C++
    515 Find Largest Value in Each Tree Row Medium no no no C++
    516 Longest Palindromic Subsequence Medium no no no C++

你可能感兴趣的:(刷题)