#2917

Find the K-or of an Array

easy · 72.7% accepted · 250 likes · top 82%

array · bit manipulation

⊣ practice⊣ open on leetcode ↗

Description

You are given an integer array nums, and an integer k. Let's introduce K-or operation by extending the standard bitwise OR. In K-or, a bit position in the result is set to 1 if at least k numbers in nums have a 1 in that position.

Return the K-or of nums.

Solution