Rhe
Rhe
最后一题 - 类似的思路 ```python class Solution: def numDistinctIslands(self, grid: List[List[int]]) -> int: journey_set = set() for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j] == 1: journey_list = []...
list超时是因为`.pop(0)`, 用list在面试只要讲清楚为了简化代码把list当成deque就行了. dong哥的思路一如既往地清晰 :p
判断isValidBST, 也可以利用BST的inorder traversal 所有元素应该是递增的属性. ```python class Solution: def __init__(self): self.prev = float('-inf') self.bool = True def isValidBST(self, root: Optional[TreeNode]) -> bool: self.inorder(root) return self.bool def inorder(self, node): if node is...
东哥 有个图挂了
@apache1011, 第三题确实感觉转换成计算最小的failure_rate再结合东哥的模板和思路会更加好理解. ```python import heapq class Solution: def _build_graph(self, n, edges, succ_probs): graph = [[] for _ in range(n)] for edge, succ_prob in zip(edges, succ_probs): graph[edge[0]].append([edge[1], succ_prob]) graph[edge[1]].append([edge[0], succ_prob]) return...
这题看了解法有点类似 [752. Open the Lock](https://leetcode.com/problems/open-the-lock/)
回复楼上 后续遍历的写法没问题 并没有超时...
Same issue... the same account and pass work for the web login