Showing posts with label Google. Show all posts
Showing posts with label Google. Show all posts

Wednesday, July 27, 2016

Find The Longest Sequence Of Prefix Shared By All The Words In A String

Write an algo­rithm to find The Longest Sequence Of Pre­fix Shared By All The Words In A String. This prob­lem is bit tricky, it looks dif­fi­cult but actu­ally it is sim­ple problem.

http://algorithms.tutorialhorizon.com/find-the-longest-sequence-of-prefix-shared-by-all-the-words-in-a-string/


Tuesday, February 28, 2012

Unbiased decision from biased coin

You are given biased coin. Find unbiased decision out of it?

Concept:

When we have a biased coin, then the probability of a head and a tail is not the same. Let us say the probability of coming up with a head(H) is p, so the the probability of tail(T) would be 1-p. The dice would be biased when p > 0.5 or vice-verse.
The task at hand is to stimulate a condition where the probability of occurrence of two events is the same. That cannot be done with a single toss of the dice, so we need to think a little out of the box.
Throw the biased coin twice.

Classify it as true for HT and false for TH. Both of these occur with probability=p*(1-p), and hence unbiased.
Ignore the other 2 events namely HH and TT.