Google interview question

string do a simple function to calc some information