IBM coding round
Anonymous User
921

I recently gave the online coding assesment for IBM Senior FE developer profile. The assesment was originally supposed to be of 2 hours with 2 questions but when I started the test I realised it was only 1 hour with 2 questions. I got stuck in below question:

You are given an integer array arr and an integer k. For any integer arr[i] the distance d is the maximum distance between 2 contiguous set bits of it's bit representation. For example 5 is represented a 101 so distance is 2 and if the number only has one set bit the distance d is -1.
Now for the given array arr you need to give top k integers with maximum distance d between their nearest set bits and 0 <= arr[i] <= 10^8
Also if two integers have same d then the output should be sorted accoding to their decimal representation. For example let's suppose integer 5 and 6 have same d then 6 is greater than 5 so output will have 6 before 5.

Comments (2)