Google Online Challenge 2021
Anonymous User
891

Position: new Grad Intern
Place: India

Time: 60 minutes

There were Two questions

  1. Harmonic sequence
    You are given an array keys of N elements. Then there will be Q queries and in each query you will be given an Integer X. You have to ans for each query in "Yes" or "No". It will be "Yes" if you can find any element in keys such that its and with X equals 0 i.e keys[i]&X==0 is satisfied else it will be "No".

Example input

3
1 2 3
5
1
2
3
4
5

Example output

Yes
Yes
No
Yes
Yes

Explanation

1&2=0
2&1=0
there is no element in keys whose and with 3 equals 0
4&1=0
5&2=0

Constraints
N<=1e5, Q<=1e5, keys[i]<=1e5, X<=1e5

  1. Distinct subsequences
    You are given a string S of length N consisting of 0s and 1s only. Convert all its subsequences into its decimal representation and return the number of distinct decimal representations formed by its subsequences.

This question is similar to Distinct Subsequences II

Example input

3
110

Example output

5

Exaplanation

Subsequences having distinct decimal representations are 1,0,11,10,110 which corresponds to 1,0,3,2,6 in decimal.

Constraints
N<=1e5

I solved first one but couldn't solve 2nd one.

Comments (2)