I think that’s not called “problem solved” in any serious company, Google included.
Even if you get this problem on some coding platform, your solution will fail on the performance part.
What would really help is to mention something like Boyer-Moore algorithm in the end, for example.