-
ChessBoardShapes [Flood Fill Algorithm]myCode/ShortestCodeChallenge 2016. 4. 21. 19:26
https://codefights.com/challenge/YPo4BxN4Mu95MksRG
3000A bored student printed out a regular
8 × 8chessboard and then used a black marker to completely fill in some of the white squares. Knowing which squares he filled in, determine the area (i.e. the number of the chessboard squares) of the largest enclosed black region on the chessboard after his actions.Example
ChessboardShapes(["g2", "h1"]) = 6.
Coloring"g2"black creates a plus-shaped black region around it consisting of5squares ("f2", "g1", "g2", "g3", "h2"). When"h1"is colored black, it connects to that region, but because it's in a corner of the chessboard, it doesn't add any new squares besides itself, thus the returned value is5 + 1 = 6.ChessboardShapes([]) = 1.
If no squares are recolored, the largest black region is just any of the originally black squares.
[input] array.string squares
White squares colored black, expressed in standard algebraic chess notation (all letters are lowercase,
"a1"is a black square).0 ≤ squares.length ≤ 32.[output] integer
The area of the largest enclosed black region.
연결되어있는 도형을 찾는 Flood-Fill 알고리즘을 이용하는 문제
참조 - https://en.wikipedia.org/wiki/Flood_fill
'myCode > ShortestCodeChallenge' 카테고리의 다른 글
DigitBuilder [Subset sum problem] (0) 2016.04.25 Last Two [Fast Exponentiation Algorithm] (0) 2016.04.21 Compress (0) 2016.04.13 The Euler's totient (0) 2016.04.07 PolynomialRoot (0) 2016.04.06