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.
Hi. I'm not sure if is possible to solve the problem using triangular number only. Triangular number is just an especific sequence and in this solution, triangular number is part of the solution. I'll try explain the solution step by step :
1) len(s) -> count all char of the word;
2) exp1 -> count all words that follow this rule: a_a also aaaa_aaaa;
3) exp2 -> count all repeated char of the word and with triangular number all combinations of these repeated chars. Example of this step is: aaaa has the combination of:
'aa'+'aa'+'aa'
+'aaa'+'aaa'
+'aaaa' = 6 (realize 6 is the same T3 of triangular number sequence).
The final answer is the sum of all these steps.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Special String Again
You are viewing a single comment's thread. Return to all comments →
Hi. I'm not sure if is possible to solve the problem using triangular number only. Triangular number is just an especific sequence and in this solution, triangular number is part of the solution. I'll try explain the solution step by step :
1) len(s) -> count all char of the word;
2) exp1 -> count all words that follow this rule: a_a also aaaa_aaaa;
3) exp2 -> count all repeated char of the word and with triangular number all combinations of these repeated chars. Example of this step is: aaaa has the combination of:
'aa'+'aa'+'aa'
+'aaa'+'aaa'
+'aaaa' = 6 (realize 6 is the same T3 of triangular number sequence).
The final answer is the sum of all these steps.