Interview 1
- Rotate array in such a way that sum of index*value is max
- In a connected graph, randomly clicked any button with prob p, then nearby switches state changes. What is the expected no of switches open.
Interview 2
- Two fair dice with 4 faces, you win if blue > black , end if blue = black and return is max (blue-black, 0). What is the expected win amount, build some recursive solution with E = prob3*(amount + E) + prob2*(amount + E) + … . solve it via coding simulation as well. (n no of loops each can have infinite no of trials)
- 2sum based, with d as the difference between the two, but avoid repetitions and count (a,b) , (b,a) as one.
Interview 3
- Hotel cancellation SD, with immediate profit improvement ,
- [1,0,0,0,1,1,0] → no of continuous subsets 4, if by prob p. with which we can get 1, what is the expected no of subsets.
Sum from 1 to n P(x)*x or use recursive formula
E(n,p) = prob getting same in boundary * E(n-1,p) + prob getting diff in boundary * (E(n-1,p) + 1)