- 博客(15)
- 资源 (2)
- 收藏
- 关注
原创 LeetCode11. Container With Most Water
Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lin
2017-03-29 13:15:51 260
原创 LeetCode6. ZigZag Conversion
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 N A P L S I I G
2017-03-28 22:06:01 354
原创 LeetCode5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: “babad”Output: “bab”Note: “aba” is also a valid answer. Example:Input:
2017-03-28 21:19:56 220
原创 LeetCode2. Add Two Numbers
You 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 numbers and return it
2017-03-27 20:53:16 226
原创 LeetCode14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.运行时间 3ms#include<string>#include<vector>#include<iostream>using namespace std;class Solution {public: stri
2017-03-27 17:00:33 271
原创 LeetCode38. Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, …1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off as “one 2, the
2017-03-27 16:28:07 295
原创 LeetCode35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here
2017-03-27 13:44:29 237
原创 LeetCode28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 从一个字符串中查找给定字符串第一次出现的位置#include<string>#include<iostream>using namespace s
2017-03-27 12:22:10 263
原创 LeetCode27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The order
2017-03-27 10:32:03 286
原创 LeetCode26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons
2017-03-27 08:46:19 223
原创 LeetCode21. Merge Two Sorted Lists
1、去重了,所以没通过#include<cstdlib>#include<iostream>using namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNo
2017-03-26 21:58:46 266
原创 LeetCode20. Valid Parentheses
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” are all valid but “
2017-03-26 18:53:36 305
原创 LeetCode13. Roman to Integer
给定一个罗马数字s,( I<=s<=MMMCMXCIX)(即1到3999),将罗马数字转换成整数。 如罗马数字I,II,III,IV,V分别代表数字1, 2, 3, 4, 5。 格式: 第一行输入一个罗马数字,接下来输出对应的整数。 提示: 首先要来了解一下罗马数字表示法,基本字符有7个:I,V,X,L,C,D,M,分别表示1,5,10,50,100,500,1000。 在构
2017-03-26 10:34:56 338
原创 LeetCode9、Palindrome Number
#include<vector>#include<cstdlib>#include<iostream>using namespace std;class Solution {public: bool isPalindrome(int x) { vector<int> v; if(x==0){return true;} if(x<0)
2017-03-26 09:09:09 354
原创 LeetCode7. Reverse Integer
1、stackclass Solution {public: int reverse(int x) { if((x==0)||(x==-2147483648)){ return 0; } bool flag=(x<0); x = abs(x); int r; stack
2017-03-26 08:46:32 302
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人