Viridien Interview Question

Interview conducted by a geophysics background engineer. Considering I'm not a software engineer background student. Questions include: 1. given 2 cups, one cup of volume 5 liter(cup1), another of volume 3 liter(cup2), no other containers allowed, with unlimited water, how to get 4 liter water in cup1? 2. the memory taken in an integer in c/c++? how many bytes? 3. given a signed int, find how many 1s in the binary representation, return the count? (in C++) 4. statistical/probabilistic question, one year 365 days, what's the probability of N people having the same birthday?

Interview Answers

Anonymous

Jan 23, 2015

1. fill cup1 5l -> pour into cup2, left 2l in cup1 -> empty cup2 -> pour 2l water in cup1 into cup2 -> fill up cup1 -> fill up cup2 to 3l with water in cup1 -> left 4 l in cup1 finally 2. just name the bytes taken for unsigned int/long, signed int/long 3. find highest 1 first by right shift >> bit manipulation, then use a test integer with only one 1 in binary representation, do a bit & to check if there's a 1 on the bit of the tested integer, and shift left 365 selections out of 1 year total case -> everyone can have 365 selections out of 1 year, so 365^N

Anonymous

Sep 4, 2019

shouldnt the last problem be (1/365)^(N-1)