class Solution
{
public:
int szx,szy;
vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int newColor)
{
szx=image.size();
szy=image[].size();
int dyenum=image[sr][sc];
dye(image,sr,sc,image[sr][sc],newColor);
return image;
} void dye(vector<vector<int>> &image,int sr,int sc,int dyenum,int newcolor)
{
if(sr<||sr>=szx||sc<||sc>=szy||image[sr][sc]!=dyenum||image[sr][sc]==newcolor)
return ;
image[sr][sc]=newcolor;
dye(image,sr-,sc,dyenum,newcolor);
dye(image,sr,sc-,dyenum,newcolor);
dye(image,sr+,sc,dyenum,newcolor);
dye(image,sr,sc+,dyenum,newcolor);
}
};

染色问题,递归,不难,代码也好理解

733. Flood Fill的更多相关文章

  1. LN : leetcode 733 Flood Fill

    lc 733 Flood Fill 733 Flood Fill An image is represented by a 2-D array of integers, each integer re ...

  2. 【Leetcode_easy】733. Flood Fill

    problem 733. Flood Fill 题意:图像处理中的泛洪填充算法,常见的有四邻域像素填充法.八邻域像素填充法.基于扫描线的像素填充法,实现方法分为递归与非递归(基于栈). 泛洪填充算法原 ...

  3. [LeetCode&Python] Problem 733. Flood Fill

    An image is represented by a 2-D array of integers, each integer representing the pixel value of the ...

  4. 733. Flood Fill 简单型染色问题

    [抄题]: An image is represented by a 2-D array of integers, each integer representing the pixel value ...

  5. 【LeetCode】733. Flood Fill 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:DFS 方法二:BFS 日期 题目地址:ht ...

  6. Leetcode之深度优先搜索(DFS)专题-733. 图像渲染(Flood Fill)

    Leetcode之深度优先搜索(DFS)专题-733. 图像渲染(Flood Fill) 深度优先搜索的解题详细介绍,点击 有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 ...

  7. [LeetCode] Flood Fill 洪水填充

    An image is represented by a 2-D array of integers, each integer representing the pixel value of the ...

  8. 和同事谈谈Flood Fill 算法

    前言 今天忙完了公司的工作后,发现同事在做LeeCode的算法题,顿时来了兴趣,于是王子与同事一起探讨如何能做好算法题,今天在此文章中和大家分享一下. 什么是Flood Fill 算法 我们今天谈论的 ...

  9. 图像处理之泛洪填充算法(Flood Fill Algorithm)

    泛洪填充算法(Flood Fill Algorithm) 泛洪填充算法又称洪水填充算法是在很多图形绘制软件中常用的填充算法,最熟悉不过就是 windows paint的油漆桶功能.算法的原理很简单,就 ...

随机推荐

  1. 1、str.join() 2、fromkeys() 3、深浅拷贝 4、set()

    1. 补充基础数据类型的相关知识点 1. str. join() 把列表变成字符串 2. 列表不能再循环的时候删除. 因为索引会跟着改变 3. 字典也不能直接循环删除. 把要删除的内容记录在列表中. ...

  2. switch只跟在这些之后

    switch case 可以用在他们之后

  3. 贪吃蛇Food Java实现(二)

    1.antition包Food类 package cn.tcc.snake.antition; import java.awt.Graphics;import java.awt.Point;publi ...

  4. TOJ 3973 Maze Again && TOJ 3128 简单版贪吃蛇

    TOJ3973传送门:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3973 时间限制(普通 ...

  5. 20 【python】入门指南:常用数据结构

    Python内置了三种高级数据结构:list,tuple,dict list:数组,相同类型的元素组成的数组 tuple:元组,相同类型的元素组成的数组,但是这里有限定条件(长度是固定的,并且值也是固 ...

  6. jquery写tab切换,三行代码搞定

    <script type="text/javascript"> $("button").on("click",function( ...

  7. listView 滑动时 滑到一半自动滑动到对应的位置

    package com.bi.demo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; impo ...

  8. SSH异常“Failed to start OpenSSH Server daemon”

    [root@bogon yum]# systemctl status sshd.service● sshd.service - OpenSSH server daemon   Loaded: load ...

  9. C语言中简单的for循环和浮点型变量

    浮点型变量:常数中带有小数点的叫做浮点型 以下用for循环写一个摄氏度和华氏度的转换的C程序 [见 http://www.linuxidc.com/Linux/2013-08/88513.htm ] ...

  10. 关于thymeleaf的if多条件判断

    <ul class="nav nav-second-level"> <li th:each="cmenu : ${menu.children}" ...