#3619

Count Islands With Total Value Divisible by K

specialist · 780 · lc medium +31 · 56.3% accepted · 64 likes · top 50%

Description

An m x n matrix grid and a positive integer k are given. An island is a maximal group of 4-directionally connected positive integers.

The total value of an island is the sum of all its cell values.

Return the count of islands whose total value is divisible by k.

Code

1
2
3