Amazon SDE 2 interview question (ANAGRAMS)
Anonymous User
6478

Did a SDE 2 interview recently and was able to answer all the rounds except this one messed up question . I think it was bar raiser but the question was Given a string
s :abccba
Print all the anagrams which are substrings of the original string
result List : ab ba bc cb abc cba bcc ccb abcc ccba abccb bccba

Now I solved it in the brute force way using a hash map to maintain the anagram key and list of anagrams
but I had no idea to optimize it

Is this a fancy sliding window question or some DP based question
Please help as I still have no idea how to solve this optimally ***

Edit : closest question I have seen to this is this
https://leetcode.com/problems/find-all-anagrams-in-a-string/
which is not really the same question

Comments (13)