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.
Normal string is java.lang.String. So whenever you append a character in a string of length N, it creates a new string, copy first string and add second character. It is of O(N). Better alternative is StringBuilder, but that will result into non-functional code. You may find some articles at SO also.
It is the expected solution. String to list of char. Yes tailrec optimization can be done. Try to figure it out. (Hint: You need reverse function also).
That's other way to solve this problem, but not expected one. It will be user's loss if he went for it. Primary goal of this contest/challenge is to lean how to solve problems functionaly.
@ Kitty_codez: (First let me present to you my previous kitty)
.
This problem doesn't use any advance DS. They use simple lists :)
PS: I am not that knowledgeable of scala. Reply was from the perspective of general FP principles.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String-o-Permute
You are viewing a single comment's thread. Return to all comments →
Reply to @ advancedxy:
reverse
function also).@ Kitty_codez: (First let me present to you my previous kitty)
.
This problem doesn't use any advance DS. They use simple lists :)
PS: I am not that knowledgeable of scala. Reply was from the perspective of general FP principles.