int count(string s){
if(s == "")
return 0;
if(s.length == 1)
return 1;
return 1 + count() //This is what I can't figure out. How to traverse the string.
//I just need a hint, not a full on answer.
}
I dont know how to traverse a string.
Hint: use substr()
in your recursion.
Also, you have two base cases. One of them has three issues:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With