Vaultedge interview question

A coding question was asked to solve