We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
the character "a" is used to form a combination which represents that the anagram of a particular substring taken into consideration exists i . e. the substring is present twice in the main string.
ex :
['i', 'f', 'a',, 'l', 'u', 'h', 'k', 'q']
[[('a', 'a')], [],[],[] [], [], [], ('a', 'a')],]
i and q are repeated twice, then we count the length , then sum up the len of list (in this case sum =2 as i and q form the anagram)
then we append the sum to the count.
each iteration of i takes i length of substring.
hope this helps
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
the character "a" is used to form a combination which represents that the anagram of a particular substring taken into consideration exists i . e. the substring is present twice in the main string. ex :
['i', 'f', 'a',, 'l', 'u', 'h', 'k', 'q']
[[('a', 'a')], [],[],[] [], [], [], ('a', 'a')],]
i and q are repeated twice, then we count the length , then sum up the len of list (in this case sum =2 as i and q form the anagram) then we append the sum to the count.
each iteration of i takes i length of substring. hope this helps