215. Castle Defence — Count the Guards
Easy · Matrix
A castle's defence grid is a 2D list of 0s and 1s. 1 means a guard is posted there. Count the total number of guards.
Examples
Example 1 Input: grid = [[1,0,1],[0,1,0],[1,1,0]] Output: 5 Explanation: Five 1s in the grid
Constraints
- 1 ≤ rows, cols ≤ 10