Calsoft interview question

coding problem in c# to implement