← All problemsSign in

3619. Count Islands With Total Value Divisible by K

LeetCodeArrayDepth-First SearchBreadth-First SearchUnion-FindMatrixOpen on judge ↗

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. Example 1: Input: grid = [[0,2,1,0,0],[0,5,0,0,5],[0,0,1,0,0

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start