intToRoman

题目

Given an integer, convert it to a roman numeral.

Input is guaranteed to be within the range from 1 to 3999.

阅读全文

isMatch

题目

Implement regular expression matching with support for ‘.’ and ‘*‘.

阅读全文

maxArea

题目

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 lines, which together with x-axis forms a container, such that the container contains the most water.

阅读全文

isPalindrome

题目

Determine whether an integer is a palindrome. Do this without extra space.

Python

1
2
3
4
5
6
7
8
9
10
class Solution:
def isPalindrome(self, x):
if x < 0 or (x%10 == 0 and x != 0):
return false
r = 0
while x > r:
r = r*10 + x%10
x = x // 10
return x == r or x == r//10

阅读全文

myAtoi

题目

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 cases.

阅读全文

reverse

题目

Reverse digits of an integer.

Example1: x = 123, return 321
Example2: x = -123, return -321

阅读全文

longestPalindrome

题目

Given a string s, find the longest palindromic substring in s.
You may assume that the maximum length of s is 1000.

阅读全文

findMedianSortedArrays

题目

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)).

阅读全文

lengthOfLongestSubstring

题目

Given a string, find the length of the longest substring without repeating characters.

阅读全文

addTwoNumbers

题目

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 as a linked list.

阅读全文