Suppose for example :
if an array is “un”,"iq,“ue”.
according to the logic whole array will be concatenated because size is less than 26. So, in the above case,u is repeated therefore the code will return 0 na??.
Can you please show the dry run for this case?
Not able to understand the logic
hello @darkshadow2708
no , we are checking about repetetion of characters in base case using frequency array.
if freqency array have entry more than one we are returning 0.
So,in the above example whole array will be concatenated to s. So,as you can see u appears 2 times.So,it will return 0. So,the output should be 0 but actual output will be 4.That’s my point of confusion.That’s why i am seeing please show the dry run for the example i have given above
see that recursive function will generate all 2^n combinations and then whichever combination will give valid and maximum length we will consider that.

but it should pass
pls try again.
It is the same logic what you have told,already tried three times.,here also and also at leetcode.Both places got tle!
pass vector by reference.
Yeah,it get accepted! but can you please explain what difference did it make?
read the difference between pass by value and pass by reference
I know the difference between the two.
call by value means just passing the value or a a copy of it ,whatever the changes made by called function will not be reflected in calling function.
but things are opposite in call by reference,here we pass the same variable so changes made at one place will be reflected everywhere.
But how does it made a difference of time here as we are not modifying the original vector?
copying takes O(n) time
whereas passing refence is O(1) .
that only reason why the code passed all test cases.
Yeah I got!
Thanks !
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
