how to solve this without loops at all
is there a way to solve this without any loops at all? (no for loops)

9 Replies
⌛
This post has been reserved for your question.
Hey @SidKid! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
You can call the count11 with let's say substrings and when it starts with "11" you return 1 + count11(11) or count11() otherwise
And when substring is of length 1 you terminate recursion by returning 0
Sure something like this should work
Should work ig
/run
Here is your java(15.0.2) output @LinusHuck
@LinusHuck in the assignment it looks like count can only take one parameter
It'd be something like this:
+ count11(str.substring(2))
if you want 111
to yield 1 instead of 2Yea that's right, I haven't noticed the last sentence
do you see what could be the problem with this attempt at the question?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.