BNY Interview Question

Triple Hackerrank Algorithm question they have asked