Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,430 views

XOR subsequences

Problem Description

 

You are given an array A, you have to create an array B which is a subsequence of A.
An array B is called valid if it satisfies both the conditions

 

  1. B[i] < B[i+1] where 1 <= i<|B|.
  2. bit_count( B[1] ^. ^ B[i-1] ^ B[i]) <= bit_count(B[i+1]) where 1 <= i < |B|.
    .........
    Let X be the Bitwise XOR of all the elements in valid array B.
    You need to find the number of different values of X that can be formed.
    Note: bit_count(t) is the number of set bits present in the binary representation of t

Problem Constraints

 

1 <= IAl <= 10^5
1 <= A[i] <= 100

 

Input Format

 

The first argument is an integer array A

 

Output Format

 

Return an integer denoting the number of different values of X that can be formed

in Online Assessments by Expert (108,110 points)
edited by | 2,430 views

Please log in or register to answer this question.

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .