Recuriter reached out to me through naukri. 1st round was programming round. Need to solve the presented problems on hackerrank portal(intellisence is available) and discuss the solution with the interviewer.
Alpha : No of times an element 'k' appears exactly 'k' consecutive times.
Beta : No of times an element 'k' appears exactly 'k' consecutive times starting at index k. (1-based indexing)
example:
input: arr=[2,2,2,4,4,4,4,3,3,3,2,2]
output: 2 (|3-1|)
Aplha - 3 (3 instances - 4,3,2)
Beta - 1 (only one instance - element 4 appears 4 times consecutively starting at index 4).
example:
input: [1,3,4,0]
output: 2
[0] => 0
[4] => 4
[4, 0] => 4
[3] => 3
[3, 0] => 3
[3, 4] => 7
[3, 4, 0] => 7
[1] => 1
[1, 0] => 1
[1, 4] => 5
[1, 4, 0] => 5
[1, 3] => 3
[1, 3, 0] => 3
[1, 3, 4] => 7
[1, 3, 4, 0] => 7
2 is the smallest whole number which is not present in the result set.
constraints:
2<= n <=4
(output) min no of transfers required <= 6