Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
class Solution { public: bool visited[55][55]; vector
> mat; const int di[4] = {0, 0, -1, 1}; const int dj[4] = {-1, 1, 0, 0}; int s_color, col, n, m; void dfs(int ci, int cj) { for(int i = 0; i < 4; i++) { int ti = ci + di[i]; int tj = cj + dj[i]; if(ti >= 0 and ti < n and tj >= 0 and tj < m and !visited[ti][tj] and mat[ti][tj] == s_color) { visited[ti][tj] = true; mat[ti][tj] = col; dfs(ti, tj); } } } vector
> floodFill(vector
>& image, int sr, int sc, int color) { mat = image; n = image.size(); m = image[0].size(); s_color = image[sr][sc]; col = color; dfs(sr, sc); mat[sr][sc] = col; return mat; } };
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)