description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: height = len(grid) width = len(grid[0]) max_path = 0 def index_gen(index): i, j = index if i > 0 and grid[i - 1][j] > 0: yield i - 1, j if i < height - 1 and ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER EXPR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER EXPR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(row, col, visited, acc=0): if (row, col) in visited: return 0 if row < 0 or col < 0 or row >= len(grid) or col >= len(grid[row]): return 0 if grid[row][col] =...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF NUMBER IF VAR VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def travel(grid, x, y, gold): def valid(c, grid): x, y = c if ( x < 0 or x > len(grid) - 1 or y < 0 or y > le...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF FUNC_DEF ASSIGN VAR VAR VAR IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR ASSIGN...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.max_gold = 0 for row in range(len(grid)): for col in range(len(grid[0])): visited = set() self.dfs(grid, 0, row, col, visited) return self.max_gold def dfs(self, gri...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR VAR RETURN VAR VAR FUNC_DEF IF VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def BFS(r, c): nonlocal best, best_path, R, C, grid if grid[r][c] > best: best = grid[r][c] best_path = set([(r, c)]) q = [(grid[r][c], r, c, set([(r, c)]))] ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST VAR VAR VAR VAR VAR FUNC_CALL VAR LIST VAR VAR WHILE VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR VAR FOR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_O...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(x, y, total): nonlocal maxTotal, visited maxTotal = max(maxTotal, total) visited.add((x, y)) for move in {(1, 0), (0, 1), (-1, 0), (0, -1)}: i = x + move[0] ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.best = 0 def rec(x, y, total): if 0 <= x < len(grid) and 0 <= y < len(grid[0]) and grid[x][y] > 0: total += grid[x][y] self.best = max(self.best, total) grid[x][...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR EXPR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(row, col, visited): if (row, col) in visited or grid[row][col] == 0: return 0 next_visited = visited | set([(row, col)]) next_pos = [(row - 1, col), (row + 1, col), (row, col...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR F...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def backtrack(grid, i, j): s = 0 temp = grid[i][j] grid[i][j] = 0 if i > 0 and grid[i - 1][j] != 0: s = max(s, backtrack(grid, i - 1, j)) if i < len(grid) - 1...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: visited = set() max_path = [0] row_len = len(grid) col_len = len(grid[0]) def gold_finder(cur_row, cur_col, visited, path_so_far): if ( cur_row < 0 or cur_row...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR RETURN IF VAR VAR VAR RETURN EXPR FUNC_CALL VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
def isValid(i, j, n, m): return i >= 0 and j >= 0 and i < n and j < m class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: directions = [(-1, 0), (0, -1), (1, 0), (0, 1)] n, m = len(grid), len(grid[0]) def dfs(i, j, curr_sum, visited): if not isValid(i,...
FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR VAR VAR VAR CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR VAR VAR VAR VAR ASSIGN VAR N...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) def initVisit(m, n): visited = {} for i in range(m): for j in range(n): visited[i, j] = -1 return visited ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FUNC_DEF IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN NUMBE...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: return max( [ self.helper(grid, row, col) for row in range(len(grid)) for col in range(len(grid[row])) ] ) def helper(self, grid, row, col): i...
CLASS_DEF FUNC_DEF VAR VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR FUNC_CALL VAR VAR VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def maxgold(self, grid, i, j, visited={}): if 0 <= i and i < len(grid) and j >= 0 and j < len(grid[0]): if (i, j) not in visited or visited[i, j] == 0: visited[i, j] = 1 if grid[i][j] != 0: value = grid[i][j] + max( ...
CLASS_DEF FUNC_DEF DICT IF NUMBER VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_C...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: final = [0] visited = set() directions = [[1, 0], [0, 1], [-1, 0], [0, -1]] def bt(current_sum=0, i=0, j=0): if ( (i, j) in visited or i < 0 or i >= l...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF NUMBER NUMBER NUMBER IF VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR N...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, A: List[List[int]]) -> int: def dfs(i, j): if not (0 <= i < m and 0 <= j < n): return 0, set() val = A[i][j] if val == 0: return 0, set() A[i][j] = 0 maxgold = 0 ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF NUMBER VAR VAR NUMBER VAR VAR RETURN NUMBER FUNC_CALL VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
hops = [[-1, 0], [1, 0], [0, 1], [0, -1]] class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: g = 0 path = set() for r in range(len(grid)): for c in range(len(grid[0])): temp = self.goldHelper(grid, r, c, path) g = max(g, tem...
ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def backtrack(r, c): grid[r][c] = -grid[r][c] maxlen = 0 for i, j in [[r + 1, c], [r - 1, c], [r, c + 1], [r, c - 1]]: if 0 <= i < M and 0 <= j < N and grid[i][j] > 0: ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR LIST LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR LIST VAR BIN_OP VAR NUMBER LIST VAR BIN_OP VAR NUMBER IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASS...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(i, j, total): if ( i < 0 or j < 0 or i >= m or j >= n or grid[i][j] == 0 or grid[i][j] > 100 ): ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.maxX = len(grid[0]) - 1 self.maxY = len(grid) - 1 self.maxGold = 0 for y in range(0, len(grid)): for x in range(0, len(grid[0])): if grid[y][x] != 0: self.hel...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR FU...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.res = 0 directions = [(0, 1), (0, -1), (-1, 0), (1, 0)] def dfs(i, j, cur, grid): if i < 0 or j < 0 or i >= len(grid) or j >= len(grid[0]) or grid[i][j] == 0: return val = g...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER RETURN ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def is_valid(self, grid, i, j): valid_i = 0 <= i <= len(grid) - 1 valid_j = 0 <= j <= len(grid[0]) - 1 if not valid_i or not valid_j: return False if grid[i][j] == 0: return False return True def find_path(self, grid, i, j, gold, ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(path, curr_sum): nonlocal res i, j = path[-1] dirs_lst = [(-1, 0), (1, 0), (0, 1), (0, -1)] find = False for di, dj in dirs_lst: ni = i + di ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR ASSIGN VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def dfs(self, i, j, gold): flag = True for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]: if 0 <= ni < self.m and 0 <= nj < self.n and self.grid[ni][nj] > 0: tmp = self.grid[i][j] self.grid[i][j] = 0 self.dfs(n...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSI...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) def walk(grid, i, j): nonlocal m, n if not grid or i < 0 or i >= m or j < 0 or j >= n: return 0 if grid[i][j] < 1: retu...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.ans = 0 def dfs(x, y, curr): curr += grid[x][y] self.ans = max(curr, self.ans) temp, grid[x][y] = grid[x][y], 0 for nx, ny in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR VAR LIST LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR LIST VAR BIN_OP VAR NUMBER LIST VAR BIN_OP VAR NUMBER IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUN...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) self.res = 0 def helper(r, c, grid, acc): acc += grid[r][c] self.res = max(self.res, acc) temp, grid[r][c] = grid[r][c], 0 for ir, ic in [[...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER IF NUMBER BIN_OP VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: direction = [(1, 0), (-1, 0), (0, 1), (0, -1)] N = len(grid) M = len(grid[0]) def dfs(src, seen, pSum): curI, curJ = src[0], src[1] if ( (curI, curJ) not in seen ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) visited = [[(False) for _ in range(n)] for _ in range(m)] self.ans = -1 def helper(i, j): if i >= m or j >= n or i < 0 or j < 0 or grid[i][j] == 0 or visited[i...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(i, j, vis): res = 0 for z1, z2 in [(-1, 0), (1, 0), (0, -1), (0, 1)]: x, y = i + z1, j + z2 if ( 0 <= x < len(grid) and 0 <= y < l...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def __init__(self): self.EMPTY = 0 self.DIR = [(1, 0), (-1, 0), (0, 1), (0, -1)] def getMaximumGold(self, grid: List[List[int]]) -> int: if not grid or not grid[0]: return 0 max_gold = 0 for i in range(len(grid)): for j in range(l...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF VAR VAR VAR IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: if not grid: return 0 x = [0, 1, 0, -1] y = [1, 0, -1, 0] m, n = len(grid), len(grid[0]) ans = -math.inf visited = [[(False) for _ in range(n)] for _ in range(m)] def helper(...
CLASS_DEF FUNC_DEF VAR VAR VAR IF VAR RETURN NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR A...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: rows = len(grid) cols = len(grid[0]) moves = [[-1, 0], [0, 1], [1, 0], [0, -1]] golds = [(i, j) for i in range(rows) for j in range(cols) if grid[i][j] != 0] visited = {} def dfs(curr_r, curr_c,...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR DICT FUNC_DEF ASSIGN VAR LIST FOR VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.res = 0 direction = [[1, 0], [-1, 0], [0, 1], [0, -1]] def dfs(i, j, cur): cur += grid[i][j] end = True for di, dj in direction: i1, j1 = i + di, j + dj ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: rows = len(grid) cols = len(grid[0]) self.ans = 0 def dfs(grid, row, col, currg): self.ans = max(self.ans, currg) if ( row >= 0 and row < rows ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: output = 0 direcs = [(0, -1), (-1, 0), (0, 1), (1, 0)] def dfs(i, j, gold, seen): nonlocal output if i < 0 or i == len(grid) or j < 0 or j == len(grid[0]) or grid[i][j] == 0: out...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR VAR FOR VAR VAR VAR IF BIN_OP VAR VAR BIN_O...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def findSum(row, col, total): if row < 0 or row >= len(grid) or col < 0 or col >= len(grid[0]): return if not grid[row][col]: return tmp = grid[row][col] ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER RETURN IF VAR VAR VAR RETURN ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMB...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(a, b, board, g, seen): nonlocal p p = max(p, g) for i, j in ((a + 1, b), (a - 1, b), (a, b + 1), (a, b - 1)): if ( 0 <= i < len(board) ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: a = len(grid) b = len(grid[0]) gold = 0 visited = [[(False) for y in range(b)] for x in range(a)] def maxgoldpath(x, y, visited): if x < 0 or x >= a or y < 0 or y >= b or grid[x][y] == 0 or ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: result = [float("-inf")] m, n = len(grid), len(grid[0]) visited = [[(False) for i in range(n)] for j in range(m)] for i in range(m): for j in range(n): self.backtrack(grid, i, j, m, n...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR NUMBER VAR FUNC...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: totals = [] def mine(m, n, g, x): if m >= 0 and m < len(x) and n >= 0 and n < len(x[m]) and x[m][n] > 0: g += x[m][n] backup = x[m][n] x[m][n] = 0 min...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) self.maxgold = 0 def isvalid(x, y): return x >= 0 and x < m and y >= 0 and y < n def backtrack(cell, gold, visited): self.maxgold = max(self.maxgold, gold...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF RETURN VAR NUMBER VAR VAR VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR LIST VAR B...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) ans = [0] def path(i, j, seen, val): ans[0] = max(ans[0], val) adjacent = [(i + 1, j), (i - 1, j), (i, j - 1), (i, j + 1)] for k, l in adjacent...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER FUNC_DEF ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR VAR VAR IF VAR NUMBER VAR VAR VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
DIRS = [(-1, 0), (1, 0), (0, -1), (0, 1)] class Solution: def getMaximumGold(self, grid): m, n = len(grid), len(grid[0]) def dfs(i, j, seen): if i >= m or i < 0 or j >= n or j < 0 or (i, j) in seen or grid[i][j] == 0: return 0 gold = 0 seen.add...
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: mx = 0 for i in range(len(grid)): for j in range(len(grid[0])): mx = max(mx, self.helper(grid, i, j)) return mx def helper(self, grid, i, j): if grid[i][j] == 0: retu...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF IF VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: marked = [([False] * len(grid[0])) for i in range(len(grid))] for r in range(len(grid)): for c in range(len(grid[0])): if grid[r][c] == 0: marked[r][c] = True def visit(r...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUN...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(i, j, v): seen.add((i, j)) dp[i][j] = max(dp[i][j], v) for x, y in ((i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)): if 0 <= x < m and 0 <= y < n and grid[x][y] and (x, y) no...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.res = 0 rows = len(grid) cols = len(grid[0]) def backtrace(i, j, tot): self.res = max(self.res, tot + grid[i][j]) gridVal = grid[i][j] grid[i][j] = 0 for a, ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def __init__(self): self.m = 0 self.n = 0 self.grid = None def getMaximumGold(self, grid: List[List[int]]) -> int: if not len(grid): return 0 self.grid = grid self.m = len(grid) self.n = len(grid[0]) ans = 0 fo...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FUNC_DEF VAR VAR VAR IF FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: num_rows = len(grid) num_cols = len(grid[0]) deltas = (-1, 0), (1, 0), (0, -1), (0, 1) def explore(y: int, x: int, score=0, visited=None) -> int: if not visited: visited = set() ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF VAR VAR NUMBER NONE IF VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR RETURN VAR IF VAR VAR VAR NUMBER VAR VAR VAR RETURN VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: if not grid: return 0 m = len(grid) n = len(grid[0]) def get(i, j): if i >= 0 and i < m and j >= 0 and j < n and grid[i][j] != 0: gold = grid[i][j] grid[i...
CLASS_DEF FUNC_DEF VAR VAR VAR IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: DIRS = [(-1, 0), (0, 1), (1, 0), (0, -1)] def getMaximumGold(self, grid: List[List[int]]) -> int: N, M = len(grid), len(grid[0]) self.res = 0 def dfs(x: int, y: int, v: int, done: set): self.res = max(self.res, v) for dx, dy in self.DIRS: ...
CLASS_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR VAR NUMB...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) res = [0] def bfs(v, x, y): seen.add((x, y)) dp[x][y] = max(dp[x][y], v) for i, j in [[0, 1], [0, -1], [1, 0], [-1, 0]]: a, b = x + i, ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: row, col = len(grid), len(grid[0]) maxgold = 0 directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] def collectgold(r, c, path, tot): nonlocal maxgold tot += grid[r][c] if tot > m...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR IF NUMBER BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: max_ = 0 n, m = len(grid), len(grid[0]) def backtrack(i, j, accum): nonlocal max_ if grid[i][j] == 0: max_ = max(max_, accum) return collected, grid[i...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR FOR VAR VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def dfs(self, i, j, gold, grid, m, n): if 0 <= i < m and 0 <= j < n: if grid[i][j] != 0: temp = grid[i][j] grid[i][j] = 0 gold = max( self.dfs(x, y, gold + temp, grid, m, n) for x, y in ((i -...
CLASS_DEF FUNC_DEF IF NUMBER VAR VAR NUMBER VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR RETU...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def __init__(self): self.max_len = 0 def isValid(self, r, c, grid): if r < 0 or c < 0 or r >= self.M or c >= self.N or grid[r][c] == 0: return False return True def dfs(self, r, c, visited, path_sum, grid): if (r, c) in visited or not self.isVal...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBE...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: n = len(grid) m = len(grid[0]) def dfs(i, j, total, visited): if ( i < 0 or i >= n or j < 0 or j >= m or grid[i][j] == 0 ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR RETURN ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR LIST VAR VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: d = [] m = len(grid) n = len(grid[0]) gold = [] for i in range(m): for j in range(n): if grid[i][j] > 0: gold.append((i, j)) d = [[1, 0], [-1, 0], ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(pos): if grid[pos[0]][pos[1]] == 0: return 0 gold = grid[pos[0]][pos[1]] grid[pos[0]][pos[1]] = 0 next_pos = [ (pos[0] - 1, pos[1]), ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: dirs = [[-1, 0], [1, 0], [0, 1], [0, -1]] m, n = len(grid), len(grid[0]) def dfs(x, y, gold): temp = grid[x][y] grid[x][y] = 0 self.max_gold = max(self.max_gold, gold + temp) ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution(object): def getMaximumGold(self, grid): self.ans = 0 def helper(grid, i, j, s): if 0 <= i < len(grid) and 0 <= j < len(grid[0]) and grid[i][j]: tmp = grid[i][j] grid[i][j] = 0 helper(grid, i + 1, j, s + tmp) ...
CLASS_DEF VAR FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
DIRECTIONS = [[1, 0], [-1, 0], [0, 1], [0, -1]] class Solution: def dfs(self, grid, i, j, memo): if memo[i][j]: return 0 memo[i][j] = True gold = 0 for direction in DIRECTIONS: x = i + direction[0] y = j + direction[1] if ( ...
ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER CLASS_DEF FUNC_DEF IF VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: numRows = len(grid) numCols = len(grid[0]) self.maxResult = float("-inf") for r in range(numRows): for c in range(numCols): if grid[r][c] > 0: self._getMaxGoldHelp...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def helper(r, c, total, visited): if ( r >= len(grid) or c >= len(grid[0]) or r < 0 or c < 0 or grid[r][c] == 0 or (r, c) in v...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR RETURN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR LIST VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.max_gold = 0 self.row = len(grid) self.col = len(grid[0]) for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j]: self.search_gold(grid, i, j,...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBE...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: max_gold = 0 for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j]: max_gold = max(max_gold, self.searchGrid(grid, i, j, 0)) return max_gold def sear...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) def bfs(i, j, path): if i < 0 or i >= m or j < 0 or j >= n or grid[i][j] == 0 or (i, j) in path: return 0 return grid[i][j] + max( [ ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR RETURN NUMBER RETURN BIN_OP VAR VAR VAR FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR LIST VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: if not grid or not grid[0]: return 0 row = len(grid) col = len(grid[0]) rval = [] for x in range(row): for y in range(col): if grid[x][y] == 0: ...
CLASS_DEF FUNC_DEF VAR VAR VAR IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR DICT VAR VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR LIST NUMBE...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) path = [(-1, 0), (1, 0), (0, -1), (0, 1)] path_indices = [0, 1, 2, 3] def value(i, j): if i < 0 or i >= m or j < 0 or j >= n: return 0 ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR RETURN NUMBER RETURN VAR VAR VAR FUNC_DEF IF VAR NUMBER VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: if len(grid) == 0 or len(grid[0]) == 0: return 0 def collectGold(r, c, goldSoFar): pts = [[0, 1], [1, 0], [-1, 0], [0, -1]] maxGold = goldSoFar for p in pts: nR =...
CLASS_DEF FUNC_DEF VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR IF NUMBER VAR FUNC_CA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) visited = set() def DFS(i, j, sum): if ( i < 0 or i == m or j < 0 or j == n or grid[i][j] == 0 ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR LIST VAR BIN_OP VAR NUMBER VAR BIN_OP VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) def dfs(i, j, g, c): if 0 <= i < m and 0 <= j < n and grid[i][j] != 0: c += grid[i][j] tmp = grid[i][j] grid[i][j] = 0 ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: res = 0 summ = 0 visited = set() for i in range(len(grid)): for j in range(len(grid[0])): if self.in_area(grid, i, j): value = self.dfs(grid, i, j, summ, visited) ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF IF FUNC_CA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) max_gold = 0 for row in range(m): for col in range(n): max_gold = max(max_gold, self.findMaxGold(grid, row, col, 0)) return max_gold def fi...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(i, j, gold_so_far): self.max_gold = max(self.max_gold, gold_so_far) if 0 <= i < len(grid) and 0 <= j < len(grid[0]) and grid[i][j] != 0: gold_amt = grid[i][j] grid[i][j] ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR LIST VAR BIN_OP VAR NUMBER LIST VAR BIN_O...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.grid, self.lr, self.lc = grid, len(grid), len(grid[0]) if grid else 0 return ( max( self.helper(i, j) for i in range(self.lr) for j in range(self.lc) ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER RETURN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUM...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: ans = [0] for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j] > 0: self.dfs(grid, i, j, [], ans) return ans[0] def dfs(self, grid, i, j, path, ans)...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR LIST VAR RETURN VAR NUMBER VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: R = len(grid) C = len(grid[0]) self.res = 0 def backtrack(i, j, cur_gold): self.res = max(self.res, cur_gold) if 0 <= i < R and 0 <= j < C and grid[i][j] != 0: gold = gri...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR EXPR FU...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: [[int]]) -> int: result = 0 for i in range(len(grid)): for j in range(len(grid[0])): result = max(self.search(grid, i, j), result) return result def search(self, grid, x, y): if x < 0 or x >= len(grid) o...
CLASS_DEF FUNC_DEF LIST LIST VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: if not grid: return 0 n, m = len(grid), len(grid[0]) dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)] self.max_gold = 0 self.v = set() def dfs(r, c, gold): self.max_gold = max(s...
CLASS_DEF FUNC_DEF VAR VAR VAR IF VAR RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER BIN_...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.ans = 0 seen = set() delta = [(1, 0), (-1, 0), (0, -1), (0, 1)] def dfs(i, j, cur=0): for di, dj in delta: new_i, new_j = i + di, j + dj if 0 <= new_i < len(grid...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF NUMBER FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR EX...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: R = len(grid) C = len(grid[0]) result = 0 directions = [(0, -1), (0, 1), (-1, 0), (1, 0)] def dfs(i, j, total=0): nonlocal result result = max(result, total) visited....
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR V...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def max_gold(i, j): if i < 0 or j < 0 or i >= len(grid) or j >= len(grid[0]) or grid[i][j] == 0: return 0 origin = grid[i][j] grid[i][j] = 0 max_count = 0 for...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSI...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def get_sum(self, grid, x, y, sum_, all_grids): if [x, y] not in all_grids and not grid[x][y] == 0: sum_ = sum_ + grid[x][y] all_grids.append([x, y]) sum_top, sum_bottom, sum_left, sum_right = sum_, sum_, sum_, sum_ if x > 0: s...
CLASS_DEF FUNC_DEF IF LIST VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def __init__(self): self.EMPTY = 0 self.DIR = [(1, 0), (-1, 0), (0, 1), (0, -1)] def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) max_gold = 0 for i in range(m): for j in range(n): if grid...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: max_gold = 0 def getMaximumGold(self, grid: List[List[int]]) -> int: nRow, nCol = len(grid), len(grid[0]) self.max_gold = max([x for r in grid for x in r]) path = [] def helper(kr, kc): up = kr == 0 or grid[kr - 1][kc] == 0 down = kr == n...
CLASS_DEF ASSIGN VAR NUMBER FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(i: int, j: int, visited: List[List[int]]) -> int: result = grid[i][j] for x, y in [[1, 0], [0, 1], [0, -1], [-1, 0]]: n_x, n_y = i + x, j + y if ( 0 <...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR VAR ASSIGN ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: max_gold = 0 m, n = len(grid), len(grid[0]) def get_max(i, j): if i < 0 or i >= m or j < 0 or j >= n or grid[i][j] == 0: return 0 tmp = grid[i][j] max_gold = 0 ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: if not grid or not grid[0]: return 0 self.ans = 0 R, C = len(grid), len(grid[0]) for r in range(R): for c in range(C): if grid[r][c] == 0: continue ...
CLASS_DEF FUNC_DEF VAR VAR VAR IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR LIST VAR VAR RETURN VAR VAR FUNC_DEF IF VAR VAR AS...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(r, c): res = grid[r][c] nxt = 0 for ro, co in [(1, 0), (-1, 0), (0, 1), (0, -1)]: nr, nc = r + ro, c + co if ( 0 <= nr < M ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CAL...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: r, c = len(grid), len(grid[0]) self.res = 0 dirs = [(1, 0), (-1, 0), (0, 1), (0, -1)] def dfs(i, j, curr): self.res = max(self.res, curr) if i < r and j < c and i >= 0 and j >= 0 and gri...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR VAR VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: l = len(grid) w = len(grid[0]) seen = set() r = 0 for x in grid: print(x) def dfs(x, y, gold): if (x, y) not in seen and 0 <= x < l and 0 <= y < w and grid[x][y]: ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: self.res = 0 for i in range(len(grid)): for j in range(len(grid[0])): self.dfs(grid, i, j, 0) return self.res def dfs(self, grid, i, j, currSum): if i > len(grid) - 1 or i < 0 or...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER RETURN IF VAR VAR ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getDegree(self, i, j, grid: List[List[int]]) -> int: deg = 0 if i > 0 and grid[i - 1][j] > 0: deg += 1 if i < len(grid) - 1 and grid[i + 1][j] > 0: deg += 1 if j > 0 and grid[i][j - 1] > 0: deg += 1 if j < len(grid[0]) ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER ...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: rl, cl = len(grid), len(grid[0]) de = (1, 0), (0, 1), (-1, 0), (0, -1) def solve(x, y, seen): temp = 0 for d in de: nx, ny = x + d[0], y + d[1] if ( ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VA...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
best = 0 def collect(grid, r, c, curr): if r >= 0 and c >= 0 and r < len(grid) and c < len(grid[0]) and grid[r][c] != 0: nonlocal best val = grid[r][c] curr += val best = max(best, curr) temp = grid[r][c] grid[r][c] = 0 collect(grid, r + 1, c, curr) ...
ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NU...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: seen, n, m = {}, len(grid), len(grid[0]) maxy, x, y = 0, [1, -1, 0, 0], [0, 0, -1, 1] dp = [([0] * m) for _ in range(n)] def path(i, j, d): mm = d for k in range(len(x)): ...
CLASS_DEF FUNC_DEF VAR VAR VAR ASSIGN VAR VAR VAR DICT FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def findMaxGold(grid, i, j): if 0 <= i < len(grid) and 0 <= j < len(grid[0]) and grid[i][j] > 0: origin = grid[i][j] grid[i][j] = 0 d = [(1, 0), (0, -1), (-1, 0), (0, 1)] ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL...
In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position you can wa...
class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: def dfs(i, j, runsum): runsum += grid[i][j] visited[i][j] = 1 dirr = [(i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)] for r, c in dirr: if r >= 0 and r < len(grid) and c ...
CLASS_DEF FUNC_DEF VAR VAR VAR FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER FOR VAR VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER E...