you got the mail for google interview na?
For Solution of all 4 problems do watch this
Watch this and perform much better