Practice Count Islands With Total Value Divisible by K
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Count Islands With Total Value Divisible by K
Problem Statement
You are given an m x n matrix grid and a positive integer k. An island is a group of positive integers (representing land) that are 4-directionally connected (horizontally or vertically). The total value of an island is the sum of the values of all cells in the island. Return the number of islands with a total value divisible by k.
Source: Count Islands With Total Value Divisible by K on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
grid = [[0,2,1,0,0],[0,5,0,0,5],[0,0,1,0,0],[0,1,4,7,0],[0,2,0,0,8]], k = 5
2
# Example 2
grid = [[3,0,3,0], [0,3,0,3], [3,0,3,0]], k = 3
6
Constraints
Related LeetCode Problems
Practice more problems similar to Count Islands With Total Value Divisible by K.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.