- 博客(12)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode : No13 Roman to Integer
题目:https://leetcode.com/problems/roman-to-integer/ Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.规则神马的忽略···耗时:170msclass Solut
2015-05-07 16:13:46 358
原创 LeetCode : No10 Regular Expression Matching
题目链接:https://leetcode.com/problems/regular-expression-matching/Implement regular expression matching with support for'.' and '*'.'.' Matches any single character.'*' Matches zero or more of t
2015-03-26 14:43:04 251
原创 LeetCode : No8 String to INteger (atoi)
题目链接:https://leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.解题的很简单想法:讲所给字符串转换为int()可识别的字符串。然后改进了以下两种情况:' -0012a42' >>> -12'+1'
2015-03-20 10:40:30 280
原创 LeetCode : No7 Reverse Integer
题目链接:https://leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321主要问题:负数:直接转换为正数后面有0:正常处理int型内存溢出:这个有点蛋
2015-03-16 16:24:17 242
LeetCode : No7 Reverse Integer
class Solution: # @return an interger def reverse(self, x): res = 0 if x<0: Flag = -1 x = -x else: Flag = 1 while (x!=0):
2015-03-16 16:17:55 95
原创 LeetCode : No6 ZigZag Conversion
题目链接:https://leetcode.com/problems/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
2015-03-16 12:04:30 186
原创 LeetCode : No5 Longest Palindromic Substring
题目链接:https://leetcode.com/problems/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
2015-03-15 20:27:08 268
原创 LeetCode : No5 Longest Palindromic Substring
题目链接:https://leetcode.com/problems/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
2015-03-15 12:40:41 88
原创 LeetCode : No3 Longest Substring Without Repeating Characters
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters. For example, the longes
2015-03-13 15:13:54 198
原创 LeetCode : No2 Add Two Numbers
题目链接:https://leetcode.com/problems/add-two-numbers/什么都不说,太简单。耗时:169ms# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x#
2015-03-13 13:10:03 240
原创 LeetCode : No4 Median of Two Sorted Arrays
题目链接:https://leetcode.com/problems/median-of-two-sorted-arrays/该问题可以这样描述:在两个升序排列数组中,寻找第k小的数。中位数就是(m+n)/2小的数。则可以通过比较A[k/2-1]和B[k/2-1]的大小,剔除前k/2个较小的数字。在寻找第k-k/2小的数字,通过递归的方式,直至找到第(m+n)/2个值。耗时
2015-03-13 11:11:50 187
原创 LeetCode : No1 Two Sum Python
题目链接:https://leetcode.com/problems/two-sum/考虑到效率问题,通过两层循环的方式,时间复杂度为O(n^2),时间溢出。解法1:利用python 自带的sorted排序,然后根据两数之和为target逐步从数组的两头向中间寻找。class Solution: # @return a tuple, (i
2015-03-11 18:51:44 402
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人