Posting this with solution provided.
The use case could be framed in a number of ways:
- Return all characters that match at the start of two strings, until they do not match
- How many characters match between two strings before one character doesn't match?
- What is the first character that doesn't match between two strings?
- etc.
For example:
If I have the strings 'Interesting' and 'Interested' they are similar for all the characters 'Interest' and then the first string ends in 'ing' while the second ends in 'ed'. Therefore, they have 8 characters in common, the first non-matching character is the 9th and the identical string is 'Interest'.
For the question in the title, the first non-matching character is number 9.
