Home  >  Article  >  Java  >  How to solve the problem of independent substrings in Java loop string

How to solve the problem of independent substrings in Java loop string

WBOY
WBOYforward
2023-05-17 16:34:19977browse

##Title description

Assume that s is an infinitely looping string "abcdefghijklmnopqrstuvwxyz", and s is a string like "...zabcdefghijklmnopqrstuvwxyza...". Now you are given another string p. Find out how many distinct strings there are in p. substrings of , such that they are also substrings of s. p contains only English lowercase letters and the length of p may be greater than 10,000.

Sample Description ##Input:

a Output
: 1Explanation
: Only 'a' is a substring of s.
Input
: cacOutput
: 2 Explanation
: Only 'a' and 'c' are children of s string.
Input
:zab Output
: 6Explanation
:'z','a','b', 'za', 'ab', 'zab' are all substrings of s.

Code:

How to solve the problem of independent substrings in Java loop string

##

The above is the detailed content of How to solve the problem of independent substrings in Java loop string. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete