← All problems
#44 Count 2D Array Element Medium

Write a GPU program that counts the number of elements with the integer value k in an 2D array of 32-bit integers. The program should count the number of elements with k in an 2D array. You are given an input 2D array input of length N x M and integer k.

Implementation Requirements

Example 1:

Input: input [[1, 2, 3],
              [4, 5, 1]]
       k = 1
Output: output = 2

Example 2:

Input: input [[5, 10],
              [5, 2]]
       k = 1
Output: output = 0

Constraints

Guided walkthrough coming soon. Below is the official starter signature in each language; the clickable line-by-line explanation hasn't been authored yet.
Problem text & starters from the official AlphaGPU/leetgpu-challenges. Solve it on leetgpu.com.