World Wide Technology interview question

Algorithm to validate a string