![](https://img-blog.csdnimg.cn/2019092715111047.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode
文章平均质量分 77
Problems and solutions on LeetCode
Xiao Cao
I prefer thinking and imaging than doing. I am looking for principles and truth.
展开
-
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).原创 2015-10-11 04:50:01 · 449 阅读 · 4 评论 -
Regular Expression Matching
题目Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire原创 2015-11-01 18:19:55 · 356 阅读 · 0 评论 -
Longest Common Prefix
题目Write a function to find the longest common prefix string amongst an array of strings.解题思路首先选出一个字符串作为标准,然后注意细节。代码public class Solution{ public String longestCommonPrefix(String[] strs){原创 2015-11-01 19:04:03 · 353 阅读 · 0 评论 -
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原创 2015-09-22 01:13:28 · 289 阅读 · 0 评论 -
Integer to English Words
题目Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Tho原创 2015-10-10 20:37:40 · 468 阅读 · 0 评论 -
9.Palindrome Number
题目Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of c原创 2015-09-20 20:43:38 · 302 阅读 · 0 评论 -
Integer to Roman
题目Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.解题思路从低位到高位分解数的每一位,然后用罗马字符串表示该位上的数,需要注意的是每次都从串头插入。因为输入数据的取值范围很小,所以可以把每位原创 2015-10-09 15:27:09 · 259 阅读 · 0 评论 -
Roman to Integer
题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.解题思路组成罗马数字的字符一共有7个,均是大写的。I=1,V=5,X=10,L=50,C=100,D=500,M=1000出现一次加一次原创 2015-10-09 14:48:32 · 231 阅读 · 0 评论 -
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 NA原创 2015-09-20 16:37:38 · 233 阅读 · 0 评论 -
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)).解题思路这道题应该有更简洁的方法,我的原创 2015-09-20 14:14:02 · 357 阅读 · 0 评论 -
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, and there exists one unique longest palindromic substring.解题思路1.使用原创 2015-09-16 13:13:11 · 377 阅读 · 0 评论 -
3.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原创 2015-08-17 02:52:15 · 647 阅读 · 0 评论 -
7.Reverse Integer
题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask原创 2015-09-15 23:11:51 · 425 阅读 · 0 评论 -
1.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 targe原创 2015-08-16 01:04:28 · 917 阅读 · 0 评论 -
2.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 a原创 2015-08-16 23:54:15 · 606 阅读 · 0 评论