upGrad Interview Question

DSA question on substrings and arrays