I recently interviewed for a tech screening at Databricks — a string-related question that comes up a lot on the forum. The question itself was fairly simple, and I hope it helps whoever interviews after me.
The question was roughly: given a longer string and a shorter pattern, find the earliest contiguous substring in the long string such that the substring contains exactly the same characters as the pattern, just possibly in a different order. If no such substring exists, return -1.
I just did it with a fixed sliding window, and wrote it through without much trouble.
Afterward we talked about the character set — things like how to handle it if it's UTF-8/Unicode.
I wrote my own tests, and it was clear they wanted me to think through a lot of edge cases. They also reminded me to think about handling exceptional situations and error returns.
The interviewer talked like a machine gun... but overall the experience was fine.
Discussion
Loading comments…