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的油漆桶功能.算法的原理很简单,就 ...
随机推荐
- 打印低头思故乡 java
public static void main(String args[][){ char poet[] = str.tocharArray(); int pos = 18; while(true){ ...
- e-olymp Problem11 Big accuracy
传送门:点我 Big accuracy The rational fraction m/n is given. Write it in the decimal notation with k digi ...
- 160. Intersection of Two Linked Lists (List;Two-Pointers)
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- Mac下Chrome浏览器的手机模拟器,开启模拟定位
项目接入百度地图,浏览器调试时需要获取定位信息. 1 打开设置->高级->内容设置->位置,将定位设置为“使用前先询问”,并清空禁止列表. 2 审查元素->Network-&g ...
- windows 2012安装不了KB2919355
直接安装KB2919355会报错 “此更新不适用于你的计算机” 此时应先安装 KB2919442 https://www.microsoft.com/zh-cn/download/confirmati ...
- 项目总结14:Windows远程连接redis(cmd指令或PowerShell指令)
1-确认远程的redis服务器是否允许被远程连接,已redis server安装在阿里云ECS上为例 1-1-确认在阿里云控制台,开放了端口6379和允许访问的IP 1-2-确认在服务器上安装redi ...
- 用脚手架创建vue项目
.创建文件地址 首先创建一个文件夹,我用的HBuilder编辑器 , 然后把文件夹拖入编辑器 , 在你创建的文件夹里面打开cmd 2.输入安装命令 : 1). npm install --global ...
- elasticsearch的索引操作和文档操作总结
参考文档:https://es.xiaoleilu.com/010_Intro/00_README.html 一.索引操作 1.查看当前节点的所有的index 查看当前节点的所有的index [roo ...
- vue生产环境部署总结
参考:http://www.cnblogs.com/vipstone/p/6910255.html 1. vue项目根目录/config/index.js更改资源生成路径 assetsPublicPa ...
- Django中反向生成models
我们在展示django ORM反向生成之前,我们先说一下怎么样正向生成代码. 正向生成,指的是先创建model.py文件,然后通过django内置的编译器,在数据库如mysql中创建出符合model. ...