- 博客(12)
- 收藏
- 关注
原创 LeetCode 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, and there exists one unique longest palindromic substring.题意就是找最长的回文子串。
2015-11-17 08:22:25
208
原创 LeetCode Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.这个题按照罗马数字的计数方法直接模拟就好,关于罗马数字的计数方法可以参考百度百科:http://baike.baidu.com/link?url=uRFEbVjfAx0do
2015-11-13 09:23:27
204
原创 LeetCode Range Sum Query - Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan
2015-11-11 22:48:25
209
原创 LeetCode String to Integer (atoi)
Implement atoi to convert a string to an integer.Requirements for atoi:The function first discards as many whitespace characters as necessary until the first non-whitespace character is foun
2015-11-10 10:21:09
232
原创 LeetCode Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo
2015-11-10 09:30:59
171
原创 LeetCode Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2015-11-10 08:58:24
225
原创 LeetCode Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.题意是数组存储的是一个数的每位数字,然后
2015-11-09 10:47:27
224
原创 LeetCode 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
2015-11-09 10:13:46
190
原创 LeetCode Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe
2015-11-09 09:24:29
225
原创 Palindrome Number
leetcode easy中的水题一个,负数不是回文,而且不用考虑把数逆转后是否溢出的情况也能AC,逆转后溢出两个数应该不会相等class Solution {public: bool isPalindrome(int x) { if(x < 0) return false; if(x < 0) x =
2015-11-09 08:54:24
249
原创 Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321这个题第一眼看上去比较简单,直接写出如下代码int reverse(int x) { if(x == 0) return x; int
2015-11-08 19:54:57
184
原创 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 NA P L S I
2015-11-07 00:18:10
123
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人