← All problems
#43 Count Array Element Medium

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

Implementation Requirements

Example 1:

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

Example 2:

Input: [5, 10, 5, 2], k = 11
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.