LintCode
CherryCheekAir
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python, LintCode, 415. 有效回文串
class Solution: """ @param s: A string @return: Whether the string is a valid palindrome """ def isPalindrome(self, s): # write your code here if s == None: ...原创 2018-05-16 17:18:12 · 287 阅读 · 0 评论 -
Python, LintCode, 453. 将二叉树拆成链表
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: a TreeNode, the...原创 2018-05-03 11:58:06 · 213 阅读 · 0 评论 -
Python, LintCode, 46. Majority Element
class Solution: """ @param: nums: a list of integers @return: find a majority number """ def majorityNumber(self, nums): # write your code here if len(nums) == 0:...原创 2018-05-09 18:56:37 · 204 阅读 · 0 评论 -
Python, LintCode, 35. 翻转链表
"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param head: n @return...原创 2018-05-09 18:45:40 · 242 阅读 · 0 评论 -
Python, LintCode, 480. 二叉树的所有路径
"""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 the...原创 2018-05-03 10:32:04 · 363 阅读 · 0 评论 -
Python, LintCode, 469. Same Tree
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param a: the root of binary...原创 2018-05-03 09:36:27 · 186 阅读 · 0 评论 -
Python, LintCode, 175. 翻转二叉树
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: a TreeNode, the...原创 2018-05-02 19:12:45 · 280 阅读 · 1 评论 -
Python, LintCode, 375. 克隆二叉树
"""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-02 18:30:19 · 332 阅读 · 0 评论 -
Python, LintCode, 53. 翻转字符串
class Solution: """ @param: s: A string @return: A string """ def reverseWords(self, s): # write your code here a = s.split() a = reversed(a) return...原创 2018-04-25 08:57:59 · 243 阅读 · 0 评论 -
Python, LintCode, 111. 爬楼梯
class Solution: """ @param n: An integer @return: An integer """ def climbStairs(self, n): # write your code here res = [0, 1, 2] if n <= 2: ...原创 2018-05-10 10:17:19 · 230 阅读 · 0 评论 -
Python, LintCode, 88. Lowest Common Ancestor of a Binary Tree
"""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 t...原创 2018-05-03 21:10:51 · 188 阅读 · 0 评论 -
Python, LintCode, 82. 落单的数
class Solution: """ @param A: An integer array @return: An integer """ def singleNumber(self, A): # write your code here temp = {} for i, item in enumerate(...原创 2018-04-28 17:00:44 · 516 阅读 · 0 评论 -
Python, LintCode, 433. 岛屿的个数
class Solution: """ @param grid: a boolean 2D matrix @return: an integer """ def numIslands(self, grid): # write your code here if len(grid) == 0 or grid == None: ...原创 2018-05-13 11:45:21 · 998 阅读 · 0 评论 -
Python, LintCode, 488. 快乐数
class Solution: """ @param n: An integer @return: true if this is a happy number or false """ def isHappy(self, n): # write your code here while True: t...原创 2018-05-12 11:09:16 · 366 阅读 · 0 评论 -
Python, LintCode, 41. 最大子数组
class Solution: """ @param nums: A list of integers @return: A integer indicate the sum of max subarray """ def maxSubArray(self, nums): # write your code here if l...原创 2018-05-12 09:00:43 · 194 阅读 · 0 评论 -
Python, LintCode, 420. 报数
class Solution: """ @param n: the nth @return: the nth sequence """ def countAndSay(self, n): # write your code here if n == 1: return "1" if n ...原创 2018-05-11 21:56:15 · 238 阅读 · 0 评论 -
Python, LintCode, 391. 数飞机
"""Definition of Interval.class Interval(object): def __init__(self, start, end): self.start = start self.end = end"""class Solution: """ @param airplanes: An interval...原创 2018-05-17 22:43:47 · 336 阅读 · 0 评论 -
Python, LintCode, 372. Delete Node in a Linked List
"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param: node: the node in ...原创 2018-05-17 11:31:41 · 178 阅读 · 0 评论 -
Python, LintCode, 627. 最长回文串
class Solution: """ @param s: a string which consists of lowercase or uppercase letters @return: the length of the longest palindromes that can be built """ def longestPalindrome(s...原创 2018-05-10 11:04:12 · 181 阅读 · 0 评论 -
Python, LintCode, 37. 反转一个3位整数
class Solution: """ @param number: A 3-digit number. @return: Reversed number. """ def reverseInteger(self, number): # write your code here h = int(number/100) ...原创 2018-04-25 08:58:12 · 1226 阅读 · 0 评论 -
Python, LintCode, 20. 骰子求和
# -*- coding: utf-8 -*-"""Created on Mon Apr 23 15:11:22 2018@author: HAN Jinghui"""class Solution: # @param {int} n an integer # @return {tuple[]} a list of tuple(sum, probability) ...原创 2018-04-25 08:58:17 · 579 阅读 · 0 评论 -
Python, LintCode, 2. 尾部的零
class Solution: """ @param: n: An integer @return: An integer, denote the number of trailing zeros in n! """ def trailingZeros(self, n): # write your code here, try to do i...原创 2018-04-25 08:58:22 · 312 阅读 · 0 评论 -
Python, LintCode, 452. 删除链表中的元素
"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param head: a ListNode ...原创 2018-04-24 17:37:35 · 187 阅读 · 0 评论 -
Python, LintCode, 73. 前序遍历和中序遍历树构造二叉树
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param inorder: A list of in...原创 2018-04-30 22:19:28 · 381 阅读 · 0 评论 -
Python, LintCode, 72. 中序遍历和后序遍历树构造二叉树
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param inorder: A list of in...原创 2018-04-30 22:03:16 · 232 阅读 · 0 评论 -
Python, LintCode, 71. 二叉树的锯齿形层次遍历
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: A Tree @ret...原创 2018-04-30 19:57:35 · 501 阅读 · 1 评论 -
Python, LintCode, 70. 二叉树的层次遍历 II
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: A tree @ret...原创 2018-04-30 19:44:00 · 157 阅读 · 0 评论 -
Python, LintCode, 69. 二叉树的层次遍历
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: A Tree @ret...原创 2018-04-30 19:38:22 · 175 阅读 · 0 评论 -
Python, LintCode, 68. 二叉树的后序遍历
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: A Tree @ret...原创 2018-04-30 11:02:08 · 203 阅读 · 0 评论 -
Python, LintCode, 67. 二叉树的中序遍历
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: A Tree @ret...原创 2018-04-30 11:00:19 · 400 阅读 · 0 评论 -
Python, LintCode, 454. 矩阵面积
class Rectangle: ''' * Define a constructor which expects two parameters width and height here. ''' # write your code here def __init__(self, width, height): self.width =...原创 2018-04-24 17:38:48 · 430 阅读 · 0 评论 -
Python, LintCode, 145. 大小写转换
class Solution: """ @param character: a character @return: a character """ def lowercaseToUppercase(self, character): # write your code here return character.upper(...原创 2018-04-24 17:40:27 · 501 阅读 · 0 评论 -
Python, LintCode, 867. 四键键盘
class Solution(object): def maxA(self, N): res = [0, 1] for i in range(2, N+1): last = i for j in range(1, i-2): last = max(last, res[j]*(i-...原创 2018-04-25 08:58:28 · 362 阅读 · 0 评论 -
Python, LintCode, 1. A + B 问题
class Solution: """ @param a: An integer @param b: An integer @return: The sum of a and b """ def aplusb(self, a, b): # write your code here carry = 0 ...原创 2018-04-25 08:58:32 · 359 阅读 · 0 评论 -
Python, LintCode, 763. Hex Conversion
class Solution: """ @param n: a decimal number @param k: a Integer represent base-k @return: a base-k number """ def hexConversion(self, n, k): # write your code here ...原创 2018-04-25 08:58:37 · 217 阅读 · 0 评论 -
Python, LintCode, 632. 二叉树的最大节点
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: # @param {TreeNode} root the root of...原创 2018-04-24 17:45:17 · 817 阅读 · 0 评论 -
Python, LintCode, 484. 交换数组两个元素
class Solution: """ @param A: An integer array @param index1: the first index @param index2: the second index @return: nothing """ def swapIntegers(self, A, index1, index2)...原创 2018-04-24 17:44:20 · 1215 阅读 · 0 评论 -
Python, LintCode, 466. 链表节点计数
"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param head: the first node ...原创 2018-04-24 17:43:25 · 893 阅读 · 0 评论 -
Python, LintCode, 463. 整数排序
class Solution: """ @param A: an integer array @return: nothing """ def sortIntegers(self, A): # write your code here for i in range(1, len(A)): for j i...原创 2018-04-24 17:42:32 · 374 阅读 · 0 评论 -
Python, LintCode, 366. 斐波纳契数列
class Solution: """ @param n: an integer @return: an ineger f(n) """ def fibonacci(self, n): # write your code here res = [0, 1] for i in range(2, n): ...原创 2018-04-24 17:41:36 · 289 阅读 · 0 评论
分享