Siemens interview question

Technical coding round on Hackerrank