Panda Guru LogoPanda
Guru

Help me with citadel OA 2024-2025

Round 1

Questions: Given an array arr of length n, find all possible distinct values of goodness that can be obtained by choosing any strictly increasing subsequence of the array. Sort the return array in non-decreasing order.

The goodness of a sequence is defined as the bitwise-OR of its elements.

Example: Consider n= 4, arr = [4, 2, 4, 1].

The strictly increasing subsequences which can be chosen to have distinct goodness values are:

So, the answer is [0, 1, 2, 4, 6], which is sorted in non-decreasing order.

Function Description: Complete the function getDistinctGoodnessValues in the editor below.

getDistinctGoodnessValues has the following parameter:

Returns:

Constraints:

Input Format For Custom Testing: The first line contains an integer, n, the number of elements in arr. Each line i of the n subsequent lines (where 0 ≤ i < n) represents the ith element of the array.

Sample Case 0:

4 3 2 4 6
0 2 3 4 6 7

Sample Case 1:

4 3 5 5 1
0 1 3 5 7
Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.