Get Distinct Goodness Values

Problem Overview

  • Find all distinct goodness values for this problem, where goodness is the bitwise-OR of any strictly increasing subsequence, and return them sorted.
  • Input: int arr[n]; Output: int[] of unique goodness values in non-decreasing order.
  • Constraints: 1 ≤ n ≤ 1e4, 1 ≤ arr[i] < 1024.
  • Context: Bitwise-OR on subsequences, typical coding interview and competition domain.
  • Company: Asked in Citadel interviews; a hiring interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: