上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 47 下一页
摘要: 补充: 1、哨兵节点 在某些实现中,可能会在第一个数据记录之前,或者最后一个数据记录之后添加 一个额外的哨兵节点或者哑元节点。 简化和加快一些列表处理的算法 。 2、对比 链表vs.动态数组 都需要动态分配内存块 动态数组: 通过索引访问和分配非常快速,时间复杂度为O(1) 添加元素(插入到数组的末 阅读全文
posted @ 2019-12-03 10:45 oldby 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 动态规划:O(N^3) class Solution: def palindromePartition(self, s: str, k: int) -> int: def cost(i, j): r = 0 while i < j: if s[i] != s[j]: r += 1 i + 阅读全文
posted @ 2019-12-02 20:24 oldby 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def countSquares(self, matrix: List[List[int]]) -> int: if not matrix: return 0 m,n = len(matrix),len(matrix[0]) dp = [0] 阅读全文
posted @ 2019-12-02 19:15 oldby 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def numOfBurgers(self, tomatoSlices: int, cheeseSlices: int) -> List[int]: t = (tomatoSlices - 2 * cheeseSlices) / 2 c = 阅读全文
posted @ 2019-12-02 18:27 oldby 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def tictactoe(self, moves: List[List[int]]) -> str: p = [[0] * 3 for _ in range(3)] if len(moves) < 5: return "Pending" f 阅读全文
posted @ 2019-12-02 18:24 oldby 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: # """ # This is Sea's API interface. # You should not implement it, or speculate about its implementation # """ #class Sea(object): # def 阅读全文
posted @ 2019-12-02 13:21 oldby 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交:动态规划 class Solution: def deleteTreeNodes(self, nodes: int, parent: List[int], value: List[int]) -> int: dp = [[0, 0]for _ in range(nodes)] 阅读全文
posted @ 2019-12-02 12:42 oldby 阅读(315) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def removeInterval(self, intervals: List[List[int]], toBeRemoved: List[int]) -> List[List[int]]: res = [] for i in interv 阅读全文
posted @ 2019-12-02 12:30 oldby 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 自己的提交: class Solution: def toHexspeak(self, num: str) -> str: num = hex(int(num)) num = str(num)[2:] res = "" for i in num: if i == "0": i = "O" if i 阅读全文
posted @ 2019-12-02 12:24 oldby 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 分治法 描述: 1、分:将问题柴分为几个子问题,这些子问题和原问题相似只是量级上小一些。 2、治:递归地解决每一个子问题,然后结合这些子问题的解决方案构造出原问题的解决方案。 例:二分搜索、快速排序、归并排序 习题 一、快速指数 题:计算 an def fast_power(x, n): if n 阅读全文
posted @ 2019-11-27 21:55 oldby 阅读(358) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 47 下一页