FirstBank (TN) interview question

Ask you solve and explain DSA logic