B
B
BitNeBolt2021-10-03 12:30:34
Algorithms
BitNeBolt, 2021-10-03 12:30:34

How to explain this test in the problem?

The essence of the problem: find the number of substrings in a string that do not contain another string. Question for this test:

abcdefgh
fgh


You can also find 28 substrings from the first 7 characters ("abcdefg"), and then 3 more from the last two ("gh"), so I get 31 lines, and in the correct answer - 30. Where is the extra substring acquired ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2021-10-03
@BitNeBolt

In your answer, in my opinion, the string "g" is included in both 28 and 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question