![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
CherryCheekAir
这个作者很懒,什么都没留下…
展开
-
Python, LeetCode, 290. 单词模式
class Solution: """ @param pattern: a string, denote pattern string @param str: a string, denote matching string @return: an boolean, denote whether the pattern string and the matching...原创 2018-05-18 10:24:42 · 320 阅读 · 0 评论 -
Python, LeetCode, 26. 删除排序数组中的重复项
class Solution: """ @param: nums: An ineger array @return: An integer """ def removeDuplicates(self, nums): # write your code here i = 0 while i+1 < len(...原创 2018-05-12 10:21:04 · 241 阅读 · 0 评论 -
Python, LeetCode, 27. 移除元素
class Solution: """ @param: A: A list of integers @param: elem: An integer @return: The new length after remove """ def removeElement(self, A, elem): # write your code ...原创 2018-05-12 09:50:37 · 133 阅读 · 0 评论 -
Python, LeetCode, 88. 合并两个有序数组
class Solution: """ @param: A: sorted integer array A which has m elements, but size of A is m+n @param: m: An integer @param: B: sorted integer array B which has n elements @param...原创 2018-05-12 10:52:14 · 497 阅读 · 0 评论 -
Python, LeetCode, 111. 二叉树的最小深度
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: The root of bin...原创 2018-04-30 12:35:03 · 824 阅读 · 0 评论 -
Python, LeetCode, 28. 实现strStr()
class Solution: """ @param: source: source string to be scanned. @param: target: target string containing the sequence of characters to match @return: a index to the first occurrence o...原创 2018-05-16 15:34:28 · 253 阅读 · 0 评论 -
Python, LeetCode, 110. 平衡二叉树
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: The root of bin...原创 2018-05-16 17:42:05 · 363 阅读 · 0 评论 -
Python, LeetCode, 2. 两数相加
"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param l1: the first list ...原创 2018-04-24 17:25:39 · 122 阅读 · 0 评论 -
Python, LeetCode, 3. 无重复字符的最长子串
class Solution: """ @param: s: a string @return: an integer """ def lengthOfLongestSubstring(self, s): # write your code here res = 0 if s is None or len(s)...原创 2018-05-09 17:40:47 · 160 阅读 · 0 评论 -
Python, LeetCode, 4. 两个排序数组的中位数
class Solution: def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ nums = [] ...原创 2018-06-08 10:53:04 · 480 阅读 · 1 评论 -
Python, LeetCode, 5. 最长回文子串
class Solution: """ @param s: input string @return: the longest palindromic substring """ def longestPalindrome(self, s): # write your code here res = "" if...原创 2018-05-10 22:48:29 · 326 阅读 · 0 评论 -
Python, LeetCode, 8. 字符串转整数 (atoi)
class Solution: def myAtoi(self, str): """ :type str: str :rtype: int """ s = str.strip() syb = 1 ptr = 0 res = 0 if len(s) ...原创 2018-06-08 12:02:37 · 854 阅读 · 0 评论 -
Python, LeetCode, 21. 合并两个有序链表
"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param l1: ListNode l1 is th...原创 2018-05-10 10:41:03 · 115 阅读 · 0 评论 -
Python, LeetCode, 20. 有效的括号
class Solution: """ @param s: A string @return: whether the string is a valid parentheses """ def isValidParentheses(self, s): # write your code here N = len(s) ...原创 2018-05-09 19:36:00 · 208 阅读 · 0 评论 -
Python, LeetCode, 56. 合并区间
"""Definition of Interval.class Interval(object): def __init__(self, start, end): self.start = start self.end = end"""class Solution: """ @param intervals: interval li...原创 2018-05-17 20:08:56 · 818 阅读 · 1 评论 -
Python, LeetCode, 1. 两数之和
class Solution: """ @param numbers: An array of Integer @param target: target = numbers[index1] + numbers[index2] @return: [index1 + 1, index2 + 1] (index1 < index2) """ def...原创 2018-04-24 17:36:11 · 71 阅读 · 0 评论 -
Python, LeetCode, 7. 反转整数
class Solution: """ @param n: the integer to be reversed @return: the reversed integer """ def reverseInteger(self, n): # write your code here -2147483648到2147 483 647 ...原创 2018-04-28 17:19:35 · 91 阅读 · 0 评论 -
Python, LeetCode, 9. 回文数
class Solution: """ @param num: a positive number @return: true if it's a palindrome or false """ def isPalindrome(self, num): # write your code here s = str(num) ...原创 2018-05-10 10:48:28 · 130 阅读 · 0 评论 -
Python, LeetCode, 66. 加一
class Solution: """ @param digits: a number represented as an array of digits @return: the result """ def plusOne(self, digits): # write your code here car = 1 ...原创 2018-05-10 10:04:35 · 196 阅读 · 0 评论 -
Python, LeetCode, 67. 二进制求和
class Solution: """ @param a: a number @param b: a number @return: the result """ def addBinary(self, a, b): # write your code here a = list(a) b = list...原创 2018-05-16 10:27:41 · 404 阅读 · 0 评论 -
Python, LeetCode, 412. Fizz Buzz
class Solution: def fizzBuzz(self, n): """ :type n: int :rtype: List[str] """ res = [] for i in range(1, n+1): if i%3 == 0: ...原创 2018-06-03 11:01:18 · 106 阅读 · 0 评论 -
Python, LeetCode, 50. Pow(x, n)
class Solution: def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ return x**n原创 2018-06-03 11:03:56 · 311 阅读 · 0 评论 -
Python, LeetCode, 13. 罗马数字转整数
class Solution: def romanToInt(self, s): """ :type s: str :rtype: int """ s_list = list(s) if len(s_list) == 0: return 0 res = 0...原创 2018-06-03 20:51:10 · 170 阅读 · 1 评论 -
Python, LeetCode, 104. 二叉树的最大深度
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The r...原创 2018-04-30 10:06:15 · 519 阅读 · 0 评论 -
Python, LeetCode, 14. 最长公共前缀
class Solution: def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if len(strs) == 0: return '' tmp = strs[0...原创 2018-06-03 21:24:15 · 471 阅读 · 0 评论 -
Python, LeetCode, 6. Z字形变换
class Solution: def convert(self, s, numRows): """ :type s: str :type numRows: int :rtype: str """ N = len(s) res = '' if numRows ==...原创 2018-06-08 16:57:46 · 747 阅读 · 0 评论