use java recursion find # of times a substring is in a string but it has...

80.2K

Verified Solution

Question

Programming

use java recursion

find # of times a substring is in a string but it has to be theexact same, no extra letters attached to it and capitalizationmatters.

input is 2 strings, output is an int

input: (\"Hello it is hello it's me hellos\" + \"hi hellllloooo hihello\" + \"hello\", \"hello\")

should output: 3

input: (\" Hello it is hello it's me hellos\" + \"hi hellllloooo hihello\" + \"hello\", \"Hello\")

should output: 1

input: (\" Hello it is hello it's me hellos\" + \"hi hellllloooo hihello\" + \"hello Hello \", \"Hello\")

should output: 2

input: (\" HELLO it is hello it's me hellos\" + \"hi hellllloooo hihello\" + \"hello Hello\", \"Hello\")

should output: 1

input: (\" HELLO it is hello it's me hellos\" + \"hi hellllloooo hihello\" + \"hello Hello\", \"\")

should output: 0

Answer & Explanation Solved by verified expert
4.2 Ratings (822 Votes)
public class SubstringRecursion public static void mainString args int times times substringHello World Welcome to new World0 Systemoutprintlntimes    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students