Reported September 2026
Walmartdynamic programming

Distinct Bitwise-OR Scores of Increasing Subsequences

Reported by candidates from Walmart's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Walmart OA. Under 2s to a working solution.
Founder's read

Walmart's September 2026 OA reports include a bitwise-OR problem where the whole solution hinges on a set per value, because arr[i] stays under 1024 and that caps how many distinct scores can exist. You get an array, you pick any strictly increasing subsequence (empty counts, score 0), and you return every distinct OR value sorted. Brute force dies at n up to 10^4. The trick is a DP over reachable OR values, not over subsequences. If you freeze on the state definition, StealthCoder is the invisible safety net running during the live OA.

The problem

A coding competition organized to recruit software developers includes a problem involving the bitwise-OR operation.
The score of a sequence is defined as the result of the bitwise-OR operation on its elements. Given an array arr of length n, identify all possible distinct scores that can be obtained by selecting any strictly increasing subsequence from the array. Return the results sorted in ascending order.
Note: A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without altering the order of the remaining elements.

Function
getDistinctScorsValues(arr: int[]) → int[]
Complete the function getDistinctScorsValues in the editor with the following parameter:
int arr[n]: an array of integers
Returns: int[]: all possible distinct score values, sorted ascending.

Examples
Example 1
arr = [4,2,4,1]
return = [0,1,2,4,6]
Example: n = 4.
arr = (4, 2, 4, 1)
There are n = 4 elements in the array. The strictly increasing subsequences that can be chosen to have distinct score values are:
Empty subsequence; score = 0
[1]; score = 1
[2]; score = 2
[4]; score = 4
[2, 4]; score = 6
There are no other strictly increasing subsequences that yield a different score value. So, the answer is (0, 1, 2, 4, 6), which is sorted in ascending order.

Constraints
1 ≤ n ≤ 10^4
1 &le; arr[i] < 1024

Reported by candidates. Source: FastPrep

Pattern and pitfall

Every OR result fits in 10 bits, so there are at most 1024 possible scores. Keep a boolean table reach[last][or], or a set of OR values per last-element value. Process the array left to right. For element x, gather every OR value from sets of last values strictly less than x, OR each with x, and add them to the set for x. Start with 0 as the empty score. A prefix-style structure over values (or a Fenwick tree of bitsets) keeps the lookup fast. The common pitfall is using <= instead of <, which lets duplicates like the two 4s in [4,2,4,1] chain together. Another is forgetting the empty subsequence, so 0 goes missing. Finally, union all sets and sort. StealthCoder is your hedge if the state design escapes you mid-assessment.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Distinct Bitwise-OR Scores of Increasing Subsequences cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Walmart's OA.

Walmart reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Distinct Bitwise-OR Scores of Increasing Subsequences FAQ

What's the trick in the Walmart distinct bitwise-OR problem?+

Values are under 1024, so only 1024 OR results exist. Track which OR values are reachable for each last element value instead of enumerating subsequences. That turns an exponential search into a bounded DP over values and scores.

How hard is this really?+

Medium to medium-hard. The idea is simple once you see the 10-bit bound, but the strictly increasing constraint plus n up to 10^4 makes naive O(n^2 * 1024) risky. You need a cleaner structure for lookups.

Does the empty subsequence count?+

Yes. The example for [4,2,4,1] includes 0 in the output. Seed your result set with 0 before processing anything, or you'll fail even simple cases.

Why do duplicates matter here?+

The subsequence must be strictly increasing, so equal values can't both be picked. In [4,2,4,1] the two 4s never combine. Query only last values strictly less than the current element.

How do I prepare in 48 hours?+

Practice a few subsequence DPs where the state is a small value range, not an index. Write one solution with bitsets or boolean arrays per value. Then test on the sample, an all-equal array, and a descending array.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Walmart.

OA at Walmart?
Invisible during screen share
Get it