摘要:
题目描述: 方法一:二分 class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: m = len(matrix) if m==0: return False n = len(matri 阅读全文
posted @ 2019-07-12 21:06
oldby
阅读(133)
评论(0)
推荐(0)
摘要:
题目描述: 方法一:O(mn) O(1) class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. 阅读全文
posted @ 2019-07-12 20:48
oldby
阅读(152)
评论(0)
推荐(0)
摘要:
题目描述: 方法: class Solution: def simplifyPath(self, path: str) -> str: stack = [] path = path.split("/") for item in path: if item == "..": if stack : st 阅读全文
posted @ 2019-07-12 20:46
oldby
阅读(117)
评论(0)
推荐(0)
摘要:
题目描述: 第一次提交:动态规划 class Solution: def minPathSum(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) for i in range(1,m): grid[i][0] = 阅读全文
posted @ 2019-07-12 19:43
oldby
阅读(277)
评论(0)
推荐(0)
摘要:
题目描述: 第一次提交: class Solution: def uniquePathsWithObstacles(self, obstacleGrid) : m = len(obstacleGrid) n = len(obstacleGrid[0]) for i in range(m): for 阅读全文
posted @ 2019-07-12 19:25
oldby
阅读(108)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: def uniquePaths(self, m: int, n: int) -> int: return int(math.factorial(m+n-2)/math.factorial(m-1)/math.factorial(n-1)) 方法二 阅读全文
posted @ 2019-07-12 18:05
oldby
阅读(136)
评论(0)
推荐(0)
摘要:
题目描述: 方法一; # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def rotat 阅读全文
posted @ 2019-07-12 17:34
oldby
阅读(132)
评论(0)
推荐(0)
摘要:
题目描述: 方法一: class Solution: import math def getPermutation(self, n: int, k: int) -> str: result = '' mod = k-1 if n==1:return '1' n_set = [str(i) for i 阅读全文
posted @ 2019-07-12 17:20
oldby
阅读(128)
评论(0)
推荐(0)
摘要:
题目描述: 方法一:O(nlogn) class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals.sort(key=lambda intervals:intervals[0]) m 阅读全文
posted @ 2019-07-12 16:12
oldby
阅读(137)
评论(0)
推荐(0)
摘要:
题目描述: 方法一:O(logn)递归: class Solution: def myPow(self, x: float, n: int) -> float: if n == 0: return 1 if n < 0: return 1/self.myPow(x,-n) if n&1: retur 阅读全文
posted @ 2019-07-12 16:07
oldby
阅读(118)
评论(0)
推荐(0)
浙公网安备 33010602011771号