BNP Paribas interview question

Standard Leetcode question on substrings