733. Flood Fill
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的更多相关文章
- 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 ...
- 【Leetcode_easy】733. Flood Fill
problem 733. Flood Fill 题意:图像处理中的泛洪填充算法,常见的有四邻域像素填充法.八邻域像素填充法.基于扫描线的像素填充法,实现方法分为递归与非递归(基于栈). 泛洪填充算法原 ...
- [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 ...
- 733. Flood Fill 简单型染色问题
[抄题]: An image is represented by a 2-D array of integers, each integer representing the pixel value ...
- 【LeetCode】733. Flood Fill 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:DFS 方法二:BFS 日期 题目地址:ht ...
- Leetcode之深度优先搜索(DFS)专题-733. 图像渲染(Flood Fill)
Leetcode之深度优先搜索(DFS)专题-733. 图像渲染(Flood Fill) 深度优先搜索的解题详细介绍,点击 有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 ...
- [LeetCode] Flood Fill 洪水填充
An image is represented by a 2-D array of integers, each integer representing the pixel value of the ...
- 和同事谈谈Flood Fill 算法
前言 今天忙完了公司的工作后,发现同事在做LeeCode的算法题,顿时来了兴趣,于是王子与同事一起探讨如何能做好算法题,今天在此文章中和大家分享一下. 什么是Flood Fill 算法 我们今天谈论的 ...
- 图像处理之泛洪填充算法(Flood Fill Algorithm)
泛洪填充算法(Flood Fill Algorithm) 泛洪填充算法又称洪水填充算法是在很多图形绘制软件中常用的填充算法,最熟悉不过就是 windows paint的油漆桶功能.算法的原理很简单,就 ...
随机推荐
- windows phpstudy如何扩展MongoDB
phpstudy如何扩展MongoDB 作者: default|标签:phpstudy MongoDB PHP|2017-9-9 10:17 phpstudy扩展MongoDB 前置工作安装PHPst ...
- 项目总结03:window.open()方法用于子窗口数据回调至父窗口,即子窗口操作父窗口
window.open()方法用于子窗口数据回调至父窗口,即子窗口操作父窗口 项目中经常遇到一个业务逻辑:在A窗口中打开B窗口,在B窗口中操作完以后关闭B窗口,同时自动刷新A窗口(或局部更新A窗口)( ...
- 用脚手架创建vue项目
.创建文件地址 首先创建一个文件夹,我用的HBuilder编辑器 , 然后把文件夹拖入编辑器 , 在你创建的文件夹里面打开cmd 2.输入安装命令 : 1). npm install --global ...
- django序列化单表的4种方法的介绍
这里主要是讲序列化单表的几种方法 先看下models中设计的表结构 from django.db import models # Create your models here. class Book ...
- tomcat启动闪退之内存不足及显著优化
增大内存: 打开catalina.bat,@echo off回车输入 set JAVA_OPTS=-server -Xms256m -Xmx512m -XX:PermSize=128M -XX:Ma ...
- apache jmeter 压力测试
前面讲了linux下的压力测试,今天来个windows下的,用jmeter为例 我用了两个apache-jmeter-3.1和apache-jmeter-4.0分别进行了测试, 前者高并发电脑卡死时间 ...
- Properties 使用
Properties 属于Map 下HashTable的小弟 属于持久的属性集,他可以保存在流中或者在流中加载. 键和值都是字符串类型. 通常用于配置文件 方法介绍: 存放键值对:setPropert ...
- SideBar 选择城市时右侧边上的 选择bar
需要定义一个SideBar的视图类 在布局文件中引用 同时在布局中设置一个textView默认不可见 当触摸时才显示 在调用的Activity中 sideBar.setOnTouchingL ...
- OnActionExecuting验证用户登录
代码 using Common; using Service; using Service.IService; using System; using System.Collections.Gener ...
- ES6 WeakMap和WeakSet的使用场景
JavaScript垃圾回收是一种内存管理技术.在这种技术中,不再被引用的对象会被自动删除,而与其相关的资源也会被一同回收. Map和Set中对象的引用都是强类型化的,并不会允许垃圾回收.这样一来,如 ...