How can we check the anagram strings pair in the distributed system?
Suppose we have N number of strings in Db(SQL or NoSQL). There are multiple services that are accepting M numbers of the string array. What is the optimized approach for this problem?
Example: Below are 5 Strings in Db: (N = 5)
- AAABBBC
- BHBH
- KLMON
- AAAC
- CCCA
Below are 3 strings for which we find anagram strings: (M = 3)
- BABABAC
- CCAC
- MONLN
Answer is:
- BABABAC ---> BABABAC ---> A3, B3, C1
- CCAC ---> CCCA ---> A1, C3
- MONLN ---> no anagram found
Comments
Post a Comment