FastPrepDistinct OR Values of Increasing Subsequences
Problems/Distinct OR Values of Increasing Subsequences

Distinct OR Values of Increasing Subsequences

Scale AI logoScale AI● HardNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Scale AI online assessment. We rebuilt the question. It looks at subsequences taken in the original order with strictly increasing values. Each subsequence has a bitwise OR score, and you count the distinct scores. The empty subsequence has score 0, and the output is in ascending order. The example [4,2,4,1] returns [0,1,2,4,6]. Our version is about 99% the same as the reported question.

The goodness of a sequence is the bitwise OR of all its elements. The empty sequence has goodness 0.

Given arr, consider every strictly increasing subsequence: chosen indices must preserve their original order, and each chosen value must be strictly larger than the previous chosen value.

Return every distinct goodness value in ascending order, including 0.

Function

distinctOrIncreasingSubsequences(arr: int[]) → int[]

Examples

Example 1

arr = [4,2,4,1]return = [0,1,2,4,6]

Distinct values come from the empty subsequence, singletons, and [2,4] with OR 6.

Example 2

arr = [3,2,4,6]return = [0,2,3,4,6,7]

For example, [3,4] contributes 7; duplicate scores are returned once.

Example 3

arr = [5,5,5]return = [0,5]

Equal values cannot follow one another in a strictly increasing subsequence.

Constraints

  • 1 <= arr.length <= 10000.
  • 1 <= arr[i] < 1024.

More Scale AI Online Assessment questions

  • Part 2: Batch Access ReviewOA · Seen Nov 2026
  • Part 1: The Narrowest KeyOA · Seen Nov 2026
  • Build Sessions from Unordered Events (Part 1)OA · Seen Oct 2026
  • Match Billing Charges to User Sessions (Part 2)OA · Seen Oct 2026
  • Four-Player Trick-Taking Card Game SimulationOA · PHONE SCREEN · Seen Aug 2026
  • Free Windows Between Busy IntervalsOA · PHONE SCREEN · Seen Apr 2026
  • Compare Labeling Worker AnnotationsOA · Seen Mar 2025
  • Count Stable Server SubsegmentsOA · Seen Nov 2024
  • Running Through Walls with Limited EnergyOA · Seen Sep 2024
  • Relative Score Graph ComponentsOA · Seen Sep 2023

Similar questions at other companies

  • Delete K Subsets for Maximum ScoreRubrik · OA
  • Optimize Discount Selection Under a Point BudgetPalantir · OA
  • Maximum Index-Weighted Sum with Disjoint SwapsVisa · OA
  • Vehicle Builds for Required Terrain (Game Adaptation)Roblox · OA
  • Bitwise XOR SubsequencesJP Morgan Chase · OA
  • Bitwise XOR SubsequencesGoldman Sachs · OA
  • Optimal Account BalancingAmazon · ONSITE INTERVIEW
  • Minimum Racks for Server ResourcesGoogle · PHONE SCREEN
  • Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
  • Smallest Sufficient TeamExpedia · ONSITE INTERVIEW

Interview reports that mention this question

  • Scale AI OA: What It Tests (2026)
  • Scale AI New Grad SWE and MLE Question Bank
  • Scale AI New Grad SWE OA Questions: 1 Experience

Scale AI interview experiences

  • Scale AI Forward Deployed Engineer Debugging Round: 1 Experience
  • Scale AI ML Research Engineering Intern Interviews: 1 Experience
  • Scale AI SWE Intern Debugging Interview: 9 Experiences
See Scale AI hiring insights
Saved
class Solution {
    public int[] distinctOrIncreasingSubsequences(int[] arr) {
        // write your code here
    }
}
Checking account…