India’s Best Job Seekers and Training Platform Forums Algorithm Solutions Discussion Given a string A consisting of n characters and a …

  • Given a string A consisting of n characters and a …

  • Akash 

    Administrator
    at

    Given a string A consisting of n characters and a string B consisting of m characters, write a function that will return the number of times A must be stated such that B is a substring of the repeated A. If B can never be a substring, return -1.

    Example:

    A = ‘abcd’

    B = ‘cdabcdab’

    The function should return 3 because after stating A 3 times, getting ‘abcdabcdabcd’, B is now a substring of A.

    You can assume that n and m are integers in the range [1, 1000].

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 21st September 2020. Attend one week free demo classes.Register Now

New Report

Close