Google Onsite question

I completely botched this interview question, and am probably going to get rejected, I got this question, and I was wondering if there were any like this.
I am recalling this question from memory.

Given a list of words of anagrams, return the amount of groups where each word has at most k differences

input: words = [rats, arts, tars, star], k = 2
output = 2
explanation:
The groups should be (rats, arts, tars) and (star)
rats and arts have 2 differences because we can change the first 2 characters and end up with the same word
tars and arts have 3 difference; however, tars, and rats have a 2 character difference which are at idx 0 and 3, so it still belongs in the same group as arts.

Comments (5)
No comments yet.