LeetCode
文章平均质量分 92
我不生产答案,只是最佳答案的搬运工。把java改写为C++,稍微修改语句或者变量命名,使其更加容易理解。
qq_27012963
这个作者很懒,什么都没留下…
展开
-
String - 5. 6.重写 14. 17. 20. 22. 38. 58. 71.
5. Longest Palindromic Substring原创 2018-05-19 10:38:38 · 237 阅读 · 0 评论 -
Math - 67. 69. 168. 171. 172. Two pointers - 28. 125.
67. Add BinaryGiven two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100...原创 2018-05-18 10:25:06 · 188 阅读 · 0 评论 -
Math - 7. 8.未做 9. 12. 13. 29. 43. 50. 60.###
7. Reverse IntegerGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321提示:原数除以10取余。检查有没有溢出。对于负数,注意C/C++ 采用向零取整的方式,又称为截断取整。答案:class Solution {public: int rev...原创 2018-05-11 09:49:30 · 170 阅读 · 0 评论 -
Linked List - 92. 109. 141. 142.143. 147. 148. 160.(138在HashTable已做)
92. Reverse Linked List IIReverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output...原创 2018-05-10 11:18:30 · 201 阅读 · 0 评论 -
Linked List - 2. 19. 21. 24. 61. 82. 83. 86.
2. Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two nu...原创 2018-05-09 12:42:25 · 362 阅读 · 0 评论 -
Hash Table - 3. 36. 49. 94. 136. 138. 166.187重做(1.18在Array中做过)
3. Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length ...原创 2018-05-05 18:34:58 · 224 阅读 · 1 评论 -
Array - 1. 11. 15. 16. 18.
1. Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use t...原创 2018-04-21 18:01:30 · 207 阅读 · 0 评论 -
Array - 26. 27. 31不会 33. 34. 35. 39. 40.
26. Remove Duplicates from Sorted ArrayGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for anoth...原创 2018-04-21 20:55:51 · 161 阅读 · 0 评论 -
Array - 41. 42. 55. 45. 48. 53. 54. 59. 56. 57.
41. First Missing Positive Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3提示:通过for while swap将每个正数放到正确的位置,然后for循环return第一个不正确数的位置,都正确retu...原创 2018-04-23 12:37:09 · 933 阅读 · 0 评论 -
Array - 62. 63. 64. 66. 73. 74. 75. 78. 79. 80
62. Unique PathsA robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying t...原创 2018-04-24 18:53:34 · 199 阅读 · 0 评论 -
Array - 81. 88. 90. 105. 106. 118. 119. 120.
81. Search in Rotated Sorted Array IISuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are given a ...原创 2018-05-03 12:21:20 · 173 阅读 · 0 评论 -
Array - 121. 122. 152. 153. 154. 162. 167. 169. 189.
121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one...原创 2018-05-04 09:39:09 · 163 阅读 · 0 评论