NCR CodeWar Question Doubt

Hello Everyone,
I wanted to ask about the recent NCR contest held at Hackerearth.

There was a question in which

a range L & R is given and we have to find the number of numbers having 101 in there Binary Representation

Constraint : L and R <= 10^18

2 Likes

I applied searching 101 pattern in binary Representation using KMP algorithm. Time limit Exceeded

Can you provide link to the original problem?

i think original question are not visible after contest.

We have to just count the numbers having 101 pattern in their binary representation.

Probably a Digit DP problem. Haven’t tried but probably is something on the lines of finding F(x) which denotes the number of numbers smaller than or equal to x satisfying the condition specified in the question. The answer can then be calculated by F(r) - F(l -1) and assuming F(0) = 0.

1 Like

Plz mention the given sample test case for more clarification of ques…

Constraints:
1 <= TestCases <= 200
1 <= L <= R <= 10^18

sample:
input:
5
2 10
5 16
8 17
1 10
8 12

output:
2
4
3
2
2

1 Like

This was a question asked in a recent college-hosted contest on Codechef

https://www.codechef.com/POLP2019/problems/SUBNUMS

2 Likes

any explanation ?

There is one question which comes in NCR hackerearth contest
problem statement - An array of n element and we have to choose the A[i] and after that the value of whole array becomes 50% of its current value we have to choose elment such that sum >=x( where x is given in each query) we have to tell how may combination will satisfy this eqaution

anyone who had solved this question can share their approach.

Liitle Difficult But Similar problem

You can find solution in editorial section

1 Like

It is same as reading accepted solution to the question mentioned by the OP, just code and no explanation at all. @ssjgz time to call you for help :sweat_smile:. Can you have a look at the question or use the Editorial/Accepted Solution and explain how it works?

2 Likes

Hey Its your question Only … Some logic Plz :grinning::smile:
@anon55659401 @vijju123

1 Like

Sorry - a bit busy for the next few days :confused:

1 Like

NVM :slight_smile:

1 Like

But Please do reply Bro :grinning: after some time

2 Likes

Do anyone receive interview call letter from NCR?