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.
I thought to use a double for loop, so we start from every position, grow every size of substring until end of string, sort it, and store the substring. When we find a pair, we count up.
cdcd expected output=5. Why?
substring sorted their count when more than 1:
c:2
d:2
cd: 3
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 →
I thought to use a double for loop, so we start from every position, grow every size of substring until end of string, sort it, and store the substring. When we find a pair, we count up.
cdcd expected output=5. Why? substring sorted their count when more than 1: c:2 d:2 cd: 3