Facebook | Phone | Anagram Substring Search

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-10-16Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e5, e6
Interview Stage: Phone Screen
Location: London
Year: unknown

Original Post Content:

Position: E5-E6
Location: London

Implement the .indexOf() function, but allow for anagrams of letters.

"actor".anagrammedIndexOf("cat") = 0 // 'act' is an anagram of 'cat'
"actor".anagrammedIndexOf("rot") = 2 // 'tor' is an anagram of 'rot'
"actor".anagrammedIndexOf("car") = -1 // no anagram of "car" appears consecutively in "actor", even though the individual characters do appear.

Simlar to https://leetcode.com/problems/find-all-anagrams-in-a-string/

Comments