Interview Question

Data Scientist Interview


Tiger Analytics

How to reverse strings with changing Position - Answered


Interview Answers

3 Answers


If two squares are chosen at random on a chessboard, what is the probability that they have a side in common? - Did't answer Answer - The corner squares are the ones. There are 4 such squares. P(selecting such a square) = 4/64 Here also, let the event of selecting an adjacent square be C, P(C)= 2/63 Now, solving all the three cases and adding them will give us the answer. Answer: P(selecting a square adjacent to 4 squares)*P(A) + P(selecting a square adjacent to 3 squares)*P(B) + P(selecting a square adjacent to 2 squares)*P(C) (36/64)*(4/63) + (24/64)*(3/63) + (4/64)*(2/63) 1/18

Anonymous on


While reversing the string. We start the loop from the initial value to the half of the string length then choose the first value and last values. Swap both the values.

Anonymous on


Total number of pairs on a chessboard = 64C2 Number of adjacent pairs = (7*8)*2 - (explanation: Every column has 7 adjacent pairs, there are 8 columns, similarly for rows) Answer = (7*8*2)/(64C2) = 1/18

KeepinItSimple on

Add Answers or Comments

To comment on this, Sign In or Sign Up.