This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import queue | |
| def minimumMoves(grid, startX, startY, goalX, goalY): | |
| # bfs with visited list and parent list | |
| # backtrack using parent links once bfs finds path to goal | |
| visited = [[0 for col in row] for row in grid] | |
| parentGrid = [[0 for col in row] for row in grid] | |
| neighborQueue = queue.Queue() | |
| neighborQueue.put((startY, startX)) | |
| turns = 0 | |
| HEIGHT, WIDTH = len(grid), len(grid[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=733 lang=python3 | |
| # | |
| # [733] Flood Fill | |
| # | |
| from collections import deque | |
| from typing import List | |
| # @lc code=start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=695 lang=python3 | |
| # | |
| # [695] Max Area of Island | |
| # | |
| from typing import List | |
| from collections import deque | |
| # @lc code=start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=567 lang=python3 | |
| # | |
| # [567] Permutation in String | |
| # | |
| from collections import Counter | |
| # @lc code=start | |
| class Solution: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=617 lang=python3 | |
| # | |
| # [617] Merge Two Binary Trees | |
| # | |
| # @lc code=start | |
| # Definition for a binary tree node. | |
| class TreeNode: | |
| def __init__(self, val=0, left=None, right=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=994 lang=python3 | |
| # | |
| # [994] Rotting Oranges | |
| # | |
| from typing import List | |
| # @lc code=start | |
| class Solution: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=542 lang=python3 | |
| # | |
| # [542] 01 Matrix | |
| # | |
| from typing import List | |
| from collections import deque | |
| # @lc code=start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=21 lang=python3 | |
| # | |
| # [21] Merge Two Sorted Lists | |
| # | |
| from typing import Optional | |
| # @lc code=start | |
| # Definition for singly-linked list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=206 lang=python3 | |
| # | |
| # [206] Reverse Linked List | |
| # | |
| from typing import Optional | |
| # @lc code=start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # @lc app=leetcode id=46 lang=python3 | |
| # | |
| # [46] Permutations | |
| # | |
| from typing import List | |
| # @lc code=start |
OlderNewer