shivam.s.kalra
BAN USER- 3of 5 votes
AnswersThere is a village in which parent prefer to have at least 1 boy. So they keep doing child until they get their first boy and then they stop doing children. What is ratio of girl/boy in such town after infinite years.
- shivam.s.kalra in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Automata
Since it contains multiple fake buckets. Therefore, each bucket must have Nth prime numbers of coin. So if N=5, take 2 coins from 1st bucket, 3 from 2nd, 5 from 3rd, 7 from 4th and 11 from 5th. Weigh them, and you can always find fake coin bucket using prime number factorization.
- shivam.s.kalra March 15, 2014arr = [2, 3, 4, 5, 6, 6, 3, 2, 1]
a,b = 0, len(arr)
while a != b:
e = int((a+b)/2)
# increasing or equal
if arr[e+1] - arr[e] > 0:
a = e+1
else:
b=e
print("Array: ", str(arr))
print("Maximum: " + str(arr[a]))
arr = [2, 3, 4, 5, 6, 6, 3, 2, 1]
a,b = 0, len(arr)
while a != b:
e = int((a+b)/2)
# increasing or equal
if arr[e+1] - arr[e] > 0:
a = e+1
else:
b=e
print("Array: ", str(arr))
print("Maximum: " + str(arr[a]))
That is not correct. He said there could be multiple buckets with fake coins. If difference is .5, it could mean that 5th bucket was fake or it could also mean 2nd and 3rd bucket are fake.
- shivam.s.kalra March 15, 2014