← Questions

First position of any anagram of a pattern in a string

0
DatabricksCodingLast asked Sep 2026

A coding interview question asked in Databricks's algorithms (two rounds) round, last asked Sep 2026. It tests strings, sliding window and hash map.

Given a text s and a pattern p, find the first place in s where some rearrangement of p appears as a contiguous substring. Return the smallest index i such that s[i : i + len(p)] has exactly the same characters as p, with the same counts…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

strings · sliding window · hash map

Your code and the AI tutor open when you unlock this question.