Question: Media.Net OA | Help Your Master| XOR Subsequences | Read Books nCdKd | IIIT Lucknow | 25th July 2023
2
Entering edit mode

Q1 Help Your Master 

Problem Description


GOAT-master got arrested in a police chase. He is trying to escape the high-tech prison he is held captive in. He needs a pass-code P for disabling all the cameras in order to escape. Passcode is the solution of matrix problem given below. Help him finding the pass-code.
You are given a matrix of order N×N. Each cell in a matrix has a value A : (o<=i,<N), which is either positive or equal to -1 (representing blocked cell)
Cells which are not blocked have distinct values. You can traverse from a cell in any direction (up, down, left or right), if there is no blockage.
For any cell Aj,j, sed-value S;,; is defined as sum of values of cells Ax, y which are multiple of Aj,j, but not reachable from A;,. For blocked cells, sed-value is -1.
Pass-code P is sum of sed-values of all the cells, modulo 1000000007.
Problem Constraints
1<=N<=1e3
1<=A[il [il<=1e6
A[il [j]=-1 for blocked cells only

Input Format

First argument is a 2-D array of integers denoting the above matrix.

Output Format

Return the sum of sed-values of all the cells, modulo 1000000007.
Example Input

Input 1:
[1, 3 ,-1, 5],
[-1,-1, -1 ,-1],
[2, 6 ,-1, 10],
[8, 7 ,- 1 ,11]]
Output 1:
68


 



Q2  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
 



Q3 Read Books nCdKd

Problem Description

There are N chapters in the library. The i-th chapter gives you A[i] knowledge. The i-th chapter can only be read after reading the (i-1)thchapter. You start reading from the first chapter. After reading the last chapter, you can again start from the first chapter.

You have to find out how many chapters you have to read in order to gain B[i] knowledge for every index i in B. If it is impossible to gain B[i] amount of knowledge, return -1.

Problem Constraints

1 <= N <= 105

IBI = N

-10<=A[i] <= 109

1 <= B[i] <= 109

Input Format

The first argument contains the array A.

The second argument contains the array B.

Output Format

Return an array denoting the number of chapters required to read to gain B[i] amount of knowledge.

Example Input

Input 1:- A = [1, 2, 1]

Output Format

Return an array denoting the number of chapters required to read to gain B[i] amount of knowledge.

Example Input

Input 1:-

A = [1, 2, 1]

B = [10, 1, 2]

Input 2-

A = [1]

B=[100]

Example Output

Output 1:- [8, 1, 2]

Output 2:- [100]

 Explanation

Explanation 1:- You read the whole book twice so 6 chapters and then again the first 2 chapters, so 8 chapters in total. Similarly 1 and 2 chapter for the rest two queries.

Explanation 2:- You read the first chapter 100 times to gain a knowledge of 100.
 

Entering edit mode
0

.

ADD REPLYlink 14 months ago
Mandar
• 0
1
Entering edit mode

Can anyone tell the approach for XOR subsequences ?

ADD COMMENTlink 15 months ago Harshit Mishra • 10

Login before adding your answer.

Similar Posts
Loading Similar Posts