Lin Duan

Results 9 comments of Lin Duan

自己 new 一个对象就好啦!

```python from heapq import * class Solution(object): def findCheapestPrice(self, n, flights, src, dst, total_stops): dic = defaultdict(list) for start, end, price in flights: dic[start].append((end, price)) stop = 0 heap =...

## 代码 ```python class Solution(object): def criticalConnections(self, n, connections): """ :type n: int :type connections: List[List[int]] :rtype: List[List[int]] """ g = collections.defaultdict(set) for u, v in connections: g[u].add(v) g[v].add(u) jump...

## 106 ```java /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val...

```python class Solution: def minCost(self, costs: List[List[int]]) -> int: if not costs: return 0 if len(costs) == 1: return min(costs[0]) for n in range(1, len(costs)): costs[n][0] = min(costs[n-1][1], costs[n-1][2]) +...

```python class Solution: def minCostII(self, costs: List[List[int]]) -> int: if not costs: return 0 if len(costs) == 1: return min(costs[0]) for i_house in range(1, len(costs)): for j_color in range(len(costs[0])): costs[i_house][j_color]...

```python class Solution: def minCostII(self, cost): res, res1=[-1, 0], [-1, 0] for x in cost: m1, m2 = float('Inf'), float('Inf') p1, p2 = -1, -1 for i, y in enumerate(x):...

88ms 答案: ```python class Solution: def minCostII(self, costs: List[List[int]]) -> int: n = len(costs) if n == 0: return 0 # This is a valid case. k = len(costs[0]) #...

我的代码: ```java class Solution { private int w; private int h; public boolean exist(char[][] board, String word) { if (board.length == 0) return false; h = board.length; w = board[0].length;...