
LeetCode
bingbushangshu
这个作者很懒,什么都没留下…
展开
-
[LeetCode]3.lengthOfLongestSubstring
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:I...原创 2019-05-24 18:04:32 · 224 阅读 · 0 评论 -
[LeetCode]5.longestPalindrome
longestPalindrome最长回文串问题描述Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: “babad”Output: “bab”Note: “aba” is a...原创 2019-05-25 20:57:49 · 174 阅读 · 0 评论 -
[LeetCode]1.Two Sum
给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]解决方案:使用map容器,遍历数组如果target-nums[i]在容器中,则返回相应结果,否则向容器添加元素vector<int> twoSum(const vector<int> &am...原创 2019-05-23 16:03:15 · 83 阅读 · 0 评论 -
[LeetCode]2. Add two num
LeetCode 2. Add two num内容描述给定两个链表代表两个非负数,求这两个数的和(2 -> 4 -> 3) + (5 -> 6 -> 4)因为 342 + 465 = 807所以返回 7 -> 0 -> 8注意进位!class ListNode {public: int val; ListNode *next;...原创 2019-05-23 16:55:58 · 293 阅读 · 0 评论 -
[LeetCode]4.ZigZag
内容描述The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L...原创 2019-06-10 21:21:43 · 107 阅读 · 0 评论 -
[LeetCode]7.inverse
文章目录题目描述代码题目描述将一个整数转化为逆序输出,比如123转为321,-123转为-321注意整数溢出代码int reverse(int x){int res=0;int temp=0;while(x!=0){temp=res*10+x%10;if((temp-x%10)/10!=res){return 0;}res=temp;x/=10;}return re...原创 2019-06-11 05:01:07 · 116 阅读 · 0 评论 -
[LeetCode]9.Palindrome Number
文章目录题目描述解题方案1 逆序整数2 左右指针题目描述Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: ...原创 2019-06-12 11:27:08 · 134 阅读 · 0 评论