leetcode
爱吃草莓的西瓜酱
这个作者很懒,什么都没留下…
展开
-
leetcode 刷题 1. Two Sum
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...原创 2019-02-21 14:29:35 · 121 阅读 · 0 评论 -
leetcode刷题 20. Valid Parentheses
20. Valid Parentheses题目描述代码class Solution {public: bool isValid(string s) { stack<char> mystack; for(int i = 0;i < s.length();i++) { if(s[i] == '(' || s[i] == '{...原创 2019-03-19 23:20:38 · 87 阅读 · 0 评论 -
leetcode刷题 19. Remove Nth Node From End of List
19. Remove Nth Node From End of List题目描述题目解读一开始做的时候以为一直是倒数第二个,我想这不是很容易,结果没看清题目,那个bug改的痛啊,以及要纪念一下第一次不看讨论区独立完成的代码。代码/*** Definition for singly-linked list.* struct ListNode {* int val;* ...原创 2019-03-19 22:59:46 · 118 阅读 · 0 评论 -
leetcode刷题15. 3sum
15. 3sum题目描述解题思路看到这题,最直接的就是先排好序,之后首尾相加与首后面的以及尾前面的比较,但是做着做着只能通过10几个test,总共有几百个test,要考虑的很多,尤其是不能有重复结果出现,需要谨慎思考。。。代码class Solution {public: vector<vector<int>> threeSum(vector<in...原创 2019-03-19 22:23:33 · 84 阅读 · 0 评论 -
leetcode刷题 11.Container With Most Water
11.Container With Most Water题目描述解题思路看到这题的第一反应就是将下标和值放在map中,然后很自然的循环比较大小;后来看看讨论区大佬的答案,瞬间惊呆,下面是大佬的代码,膜拜。。代码class Solution {public: int maxArea(vector<int>& height) { int maxinum...原创 2019-03-19 19:37:59 · 133 阅读 · 0 评论 -
leetcode刷题 之 8. String to Integer (atoi)
8. String to Integer (atoi)Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is...原创 2019-02-26 10:15:19 · 123 阅读 · 0 评论 -
leetcode刷题之 7. Reverse Integer
7. Reverse IntegerGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21代码clas...原创 2019-02-26 09:12:24 · 101 阅读 · 0 评论 -
leetcode 刷题 3. Longest Substring Without Repeating Characters
Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer...原创 2019-02-21 20:05:51 · 99 阅读 · 0 评论 -
leetcode 刷题 2. Add Two Numbers
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...原创 2019-02-21 18:01:16 · 105 阅读 · 0 评论 -
;eetcode刷题 21. Merge Two Sorted Lists
21. Merge Two Sorted Lists题目描述Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1-&g...原创 2019-03-20 18:18:33 · 170 阅读 · 0 评论