G’s interview, 2 questions

原帖地址:mitbbs

1: Given a string S, return minimum number of chars that you can add to its
back to obtain a palindrome. Explain the complexity

2: Write a function to return expected number of tosses of an unbiased or
biased coin until there are m (>= 1) heads in a row,supposing the head
probability in a toss is p: 0 < p <= 1. If the result is not integer, round
it.