Skip to content

Practice Find the K-or of an Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2917
LeetCode Problem

Find the K-or of an Array

Problem Statement

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.

Source: Find the K-or of an Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [7,12,9,8,9,15], k = 4
Output
9

# Example 2

Input
nums = [2,12,1,11,4,5], k = 6
Output
0

# Example 3

Input
nums = [10,8,5,9,11,6,8], k = 1
Output
15

Constraints

1 <= nums.length <= 50
0 <= nums[i] < 2^31
1 <= k <= nums.length

Related LeetCode Problems

Practice more problems similar to Find the K-or of an Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.