Soliton Technologies interview question

Problem soving using DSA using python code.