# Sharechat Hackerearth Intern

**URL:** <https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167>\
**Category:** help\
**Created:** [July 26, 2020, 8:53am UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167 "2020-07-26T08:53:44Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![ay2306](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ay2306/32/34355_2.png) [@ay2306](https://discuss.codechef.com/u/ay2306)\
**Post date:** [July 27, 2020, 4:37pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/23 "2020-07-27T16:37:54Z")

</div>

I used digit dp + binary search

digit dp -\> find number of lucky numbers till x

then we need to find `k + count(l-1)`

just run binary search over it.

---

<div class="post-metadata">

**Author:** ![mkitkat](https://discuss.codechef.com/user_avatar/discuss.codechef.com/mkitkat/32/23077_2.png) [@mkitkat](https://discuss.codechef.com/u/mkitkat)\
**Post date:** [July 27, 2020, 5:01pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/24 "2020-07-27T17:01:14Z")

</div>

Thanks man, appreciated

---

<div class="post-metadata">

**Author:** ![codeislove](https://discuss.codechef.com/user_avatar/discuss.codechef.com/codeislove/32/3653_2.png) [@codeislove](https://discuss.codechef.com/u/codeislove)\
**Post date:** [July 28, 2020, 4:49am UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/25 "2020-07-28T04:49:58Z")

</div>

How much did you score ? i followed the same approach and score 21 only … rest were WA. And what can be expected cutoff according to you ?

---

<div class="post-metadata">

**Author:** ![ay2306](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ay2306/32/34355_2.png) [@ay2306](https://discuss.codechef.com/u/ay2306)\
**Post date:** [July 28, 2020, 5:49am UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/26 "2020-07-28T05:49:44Z")

</div>

I cannot say about expected cutoff. I got full score.

---

<div class="post-metadata">

**Author:** ![rohitj](https://discuss.codechef.com/user_avatar/discuss.codechef.com/rohitj/32/29160_2.png) [@rohitj](https://discuss.codechef.com/u/rohitj)\
**Post date:** [July 28, 2020, 6:59am UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/27 "2020-07-28T06:59:04Z")

</div>

last time I got 164/170. this time 20/170. sad rxn.

---

<div class="post-metadata">

**Author:** ![codeislove](https://discuss.codechef.com/user_avatar/discuss.codechef.com/codeislove/32/3653_2.png) [@codeislove](https://discuss.codechef.com/u/codeislove)\
**Post date:** [July 28, 2020, 3:45pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/28 "2020-07-28T15:45:56Z")

</div>

If anybody receive any mail regarding results, please let us know here .

---

<div class="post-metadata">

**Author:** ![nikiitp18](https://discuss.codechef.com/user_avatar/discuss.codechef.com/nikiitp18/32/24644_2.png) [@nikiitp18](https://discuss.codechef.com/u/nikiitp18)\
**Post date:** [July 28, 2020, 4:23pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/29 "2020-07-28T16:23:12Z")

</div>

Do we have to find Kth lucky number, or if Kth number is lucky or not??

---

<div class="post-metadata">

**Author:** ![ram\_kumar14](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@ram\_kumar14](https://discuss.codechef.com/u/ram_kumar14)\
**Post date:** [July 28, 2020, 8:46pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/30 "2020-07-28T20:46:36Z")

</div>

Kth lucky number

---

<div class="post-metadata">

**Author:** ![nkhurana](https://discuss.codechef.com/user_avatar/discuss.codechef.com/nkhurana/32/10888_2.png) [@nkhurana](https://discuss.codechef.com/u/nkhurana)\
**Post date:** [July 31, 2020, 1:14pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/31 "2020-07-31T13:14:31Z")

</div>

Can you please explain your DP. I’m able to find for powers of 2 using bits but not able to generalise it. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ay2306](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ay2306/32/34355_2.png) [@ay2306](https://discuss.codechef.com/u/ay2306)\
**Post date:** [July 31, 2020, 2:22pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/32 "2020-07-31T14:22:25Z")

</div>

```cpp
#define int long long
vector<short> num;
int dp[65][2][8][2];

int solve(short pos = 0, bool f = 0, short mask = 0, bool valid = false){
    if(pos == num.size())return valid;
    int &res = dp[pos][f][mask][valid];
    if(~res)return res;
    short lst = 1;
    if( !f) lst = num[pos];
    res = 0;
    for(short i = 0; i <= lst; ++i){
       short newMask = 0;
       if(mask&1)newMask+=2;
       if(mask >> 1 & 1)newMask+=4;
       if(i)newMask++;
       res+=solve(pos+1, f || (i < lst), newMask, valid || (newMask == 5));
    }
   return res;
}

int cnt(int k){
   num.clear();
   while(k)num.emplace_back(k%2),k/=2;
   memset(dp,-1,sizeof(dp));
   return solve();
}

signed main(){
  int t;
  cin >> t;
  while(t--){
      int l,r,k;
      cin >> l >> r >> k;
      if(l) k += cnt(l-1);
      int lo = l, hi = r, ans = -1;
      while(lo <= hi){
           int mi = lo + hi >> 1;
           if(cnt(mi) >= k)ans = mi, hi = mi - 1;
          else lo = mi + 1;
      }
      cout << ans << "\n";
 }
  return 0;
}

```

---

<div class="post-metadata">

**Author:** ![ram\_kumar14](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@ram\_kumar14](https://discuss.codechef.com/u/ram_kumar14)\
**Post date:** [July 31, 2020, 2:24pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/33 "2020-07-31T14:24:19Z")

</div>

Did u got the mail after test?

---

<div class="post-metadata">

**Author:** ![nkhurana](https://discuss.codechef.com/user_avatar/discuss.codechef.com/nkhurana/32/10888_2.png) [@nkhurana](https://discuss.codechef.com/u/nkhurana)\
**Post date:** [July 31, 2020, 2:56pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/34 "2020-07-31T14:56:43Z")

</div>

Really cool. Thanks!

---

<div class="post-metadata">

**Author:** ![ay2306](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ay2306/32/34355_2.png) [@ay2306](https://discuss.codechef.com/u/ay2306)\
**Post date:** [July 31, 2020, 4:14pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/35 "2020-07-31T16:14:55Z")

</div>

No 😅

---

<div class="post-metadata">

**Author:** ![chaudhary\_19](https://discuss.codechef.com/user_avatar/discuss.codechef.com/chaudhary_19/32/41637_2.png) [@chaudhary\_19](https://discuss.codechef.com/u/chaudhary_19)\
**Post date:** [July 31, 2020, 6:05pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/36 "2020-07-31T18:05:30Z")

</div>

Anybody who scored well in this test got the call till now? I mean I scored 95 in this test and I am sure that I would not be called but if anybody got the call for this, please reply!

---

<div class="post-metadata">

**Author:** ![chaudhary\_19](https://discuss.codechef.com/user_avatar/discuss.codechef.com/chaudhary_19/32/41637_2.png) [@chaudhary\_19](https://discuss.codechef.com/u/chaudhary_19)\
**Post date:** [July 31, 2020, 6:09pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/37 "2020-07-31T18:09:03Z")

</div>

you got the interview call from last time?

---

<div class="post-metadata">

**Author:** ![chaudhary\_19](https://discuss.codechef.com/user_avatar/discuss.codechef.com/chaudhary_19/32/41637_2.png) [@chaudhary\_19](https://discuss.codechef.com/u/chaudhary_19)\
**Post date:** [July 31, 2020, 6:56pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/39 "2020-07-31T18:56:21Z")

</div>

Yeah, I know you scored full in that too (that’s not something new XD). If they are not hiring you, whom for they are looking gennady or Petr? hahaha

---

<div class="post-metadata">

**Author:** ![ay2306](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ay2306/32/34355_2.png) [@ay2306](https://discuss.codechef.com/u/ay2306)\
**Post date:** [July 31, 2020, 7:22pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/40 "2020-07-31T19:22:20Z")

</div>

I agree to your point that he is awesome, but when it comes to hiring maybe after some point in competitive, it may not matter. I am saying this just as a discussion topic and not as a comment on any individual that maybe there are better candidate who show enough problem solving but are better developers.

---

<div class="post-metadata">

**Author:** ![first\_semester](https://discuss.codechef.com/user_avatar/discuss.codechef.com/first_semester/32/13026_2.png) [@first\_semester](https://discuss.codechef.com/u/first_semester)\
**Post date:** [July 31, 2020, 7:31pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/41 "2020-07-31T19:31:49Z")

</div>

You all guys are awesome 🙂

---

<div class="post-metadata">

**Author:** ![codeislove](https://discuss.codechef.com/user_avatar/discuss.codechef.com/codeislove/32/3653_2.png) [@codeislove](https://discuss.codechef.com/u/codeislove)\
**Post date:** [August 1, 2020, 5:13am UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/42 "2020-08-01T05:13:45Z")

</div>

But they have not selected anybody . They just took the test and interviews and then gone silent until and unless I had to call up the HR to get things clear . I hope this time they do not repeat this unprofessional behavior. (Sad to realize that I will not even clear coding test this time)

---

<div class="post-metadata">

**Author:** ![ram\_kumar14](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@ram\_kumar14](https://discuss.codechef.com/u/ram_kumar14)\
**Post date:** [August 3, 2020, 6:30pm UTC](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167/43 "2020-08-03T18:30:24Z")

</div>

Bro what did they ask in interview?

[Previous page](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167.md?page=1)

[Next page](https://discuss.codechef.com/t/sharechat-hackerearth-intern/73167.md?page=3)
