Amazon Interview Question

all the inputs for the coding question were given in the form of string.