Jain Software interview question

Question realted to algorithm.