{"id":87,"date":"2022-01-02T01:30:43","date_gmt":"2022-01-02T01:30:43","guid":{"rendered":"https:\/\/danielpgleason.com\/?p=87"},"modified":"2022-05-03T15:38:02","modified_gmt":"2022-05-03T15:38:02","slug":"leetcode-733-floodfill","status":"publish","type":"post","link":"https:\/\/danielpgleason.com\/index.php\/2022\/01\/02\/leetcode-733-floodfill\/","title":{"rendered":"Leetcode 733 &#8211; FloodFill"},"content":{"rendered":"\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"flood_fill.py\" data-lang=\"Python\"><code>class Solution:\n    \n    def fill(self, image: List[List[int]], sr: int, sc: int, starting_color: int, newColor: int) -&gt; List[List[int]]:\n        if sr &lt; 0 or sc &lt; 0 or sr &gt;= len(image) or sc &gt;= len(image[0]) or image[sr][sc] != starting_color:\n            return\n        image[sr][sc] = newColor\n        self.fill(image, sr + 1, sc, starting_color, newColor)\n        self.fill(image, sr - 1, sc, starting_color, newColor)\n        self.fill(image, sr, sc + 1, starting_color, newColor)\n        self.fill(image, sr, sc - 1, starting_color, newColor)\n        \n    \n    def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -&gt; List[List[int]]:\n        if image[sr][sc] == newColor:\n            return image\n        self.fill(image, sr, sc, image[sr][sc], newColor)\n        return image\n<\/code><\/pre><\/div>\n\n\n\n<p>This is my solution for the flood fill problem in python. <\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/leetcode.com\/problems\/flood-fill\/\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This is my solution for the flood fill problem in python.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-algorithms"],"_links":{"self":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts\/87"}],"collection":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":1,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts\/87\/revisions\/88"}],"wp:attachment":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}