leetcode
Singlerush
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 1. Two Sum
LeetCode 1. Two Sum Given 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 m原创 2017-05-16 23:08:27 · 241 阅读 · 0 评论 -
LeetCode 12. Integer to Roman
Given an integer, convert it to a roman numeral. Note: Input is guaranteed to be within the range from 1 to 3999.阿拉伯数字转成罗马数字。[转载]罗马数字规则 因为数字小于4000,最多4位数字。class Solution { public: string intToRoma原创 2017-09-09 10:45:20 · 325 阅读 · 0 评论 -
LeetCode 11. 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-09-09 10:39:02 · 249 阅读 · 0 评论 -
LeetCode 472. Concatenated Words
Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entire原创 2017-09-08 21:25:31 · 360 阅读 · 0 评论 -
LeetCode 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 这题就是找一堆字符串中最长的公共前缀。 直接暴力求解就行。 先取第一个字符串第一个字符,看看是不是所有其他字符串的第一个字符都和它一样,如果一样就继续看第二个字符,如果不一样就退出循环。但是,这个最长的长度不能超过长度最小的原创 2017-09-08 20:53:02 · 231 阅读 · 0 评论 -
LeetCode 15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain duplic原创 2017-06-09 12:37:43 · 302 阅读 · 0 评论 -
LeetCode 4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1: nums1 = [1, 3]原创 2017-05-21 12:07:26 · 288 阅读 · 0 评论 -
LeetCode 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. 这个题是判断一个数是不是回文数。 需要注意的是这个数反转后可能比较大,如:1111111117<2147483647,反转后7111111111>2147483647,所以在这个题中我用了long long int去记录反转后的数。 负数因为有负原创 2017-06-02 11:25:59 · 313 阅读 · 0 评论 -
LeetCode 8. String to Integer (atoi)
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input case原创 2017-06-02 11:05:59 · 268 阅读 · 0 评论 -
LeetCode 7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321 这个题比较简单,就是数字逆序输出。class Solution { public: int reverse(int x) { int sign = x>=0?1:-1; int原创 2017-05-22 12:23:48 · 268 阅读 · 0 评论 -
LeetCode 6. 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原创 2017-05-21 15:03:15 · 243 阅读 · 0 评论 -
LeetCode 5. 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. Exam原创 2017-05-21 14:17:08 · 235 阅读 · 0 评论 -
LeetCode 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “b”, with th原创 2017-05-21 11:24:29 · 274 阅读 · 0 评论 -
LeetCode 2. 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-05-21 10:50:30 · 302 阅读 · 0 评论 -
LeetCode 13. Roman to Integer
Given a roman numeral, convert it to an integer. Note: Input is guaranteed to be within the range from 1 to 3999.与之前的正好相反。 LeetCode 12. Integer to Romanclass Solution { public: int romanToInt(str原创 2017-09-09 10:53:32 · 317 阅读 · 0 评论
分享