From 5bdc00e5ca490c61daf30edcdb4bdb772f67c069 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Fri, 17 May 2024 18:24:05 +0200 Subject: [PATCH] =?UTF-8?q?style(kt):=20reformat=20=E2=80=B9695.=20Max=20A?= =?UTF-8?q?rea=20of=20Island=E2=80=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • reformat • rename function to follow camel-case convention Signed-off-by: Matej Focko --- kt/max-area-of-island.kt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/kt/max-area-of-island.kt b/kt/max-area-of-island.kt index 4ba34b4..4fefe4a 100644 --- a/kt/max-area-of-island.kt +++ b/kt/max-area-of-island.kt @@ -1,11 +1,18 @@ -fun product(xs: Sequence, ys: Sequence): Sequence> = - xs.flatMap { x -> ys.map { y -> x to y } } +fun product( + xs: Sequence, + ys: Sequence, +): Sequence> = xs.flatMap { x -> ys.map { y -> x to y } } -fun product(xs: Iterable, ys: Iterable): Sequence> = - product(xs.asSequence(), ys.asSequence()) +fun product( + xs: Iterable, + ys: Iterable, +): Sequence> = product(xs.asSequence(), ys.asSequence()) class Solution { - fun BFS(grid: Array, coords: Pair): Int { + fun runBFS( + grid: Array, + coords: Pair, + ): Int { val queue = ArrayDeque>() queue.addLast(coords) @@ -34,6 +41,5 @@ class Solution { return size } - fun maxAreaOfIsland(grid: Array): Int = - product(grid.indices, grid.first().indices).map { BFS(grid, it) }.max() ?: 0 + fun maxAreaOfIsland(grid: Array): Int = product(grid.indices, grid.first().indices).map { runBFS(grid, it) }.max() ?: 0 }