• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
November 09, 2024 |200 Views

PROBLEM OF THE DAY : 08/11/2024 | Minimum Repeat to Make Substring

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Geetesh Yadav We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of String but also build up problem-solving skills.

Given two strings s1 and s2. Return a minimum number of times s1 has to be repeated such that s2 is a substring of it. If s2 can never be a substring then return -1.

Note: Both the strings contain only lowercase letters.

Examples:

Input: s1 = "ww", s2 = "www" Output: 2 Explanation: Repeating s1 two times (wwww), s2 is a substring of it.
 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/minimum-times-a-has-to-be-repeated-such-that-b-is-a-substring-of-it--170645/0