Visa Inc. Interview Question

Question on string DSA and sql query in leetcode