Given a set of strings (building blocks), find the length of the smallest string such that there is more than one way to build it.

Правка en1, от pabloskimg, 2021-06-10 00:56:10

For example, if the set of building block strings is {"10", "01", "101"}, the smallest string that can be formed in multiple ways is "10101", since it can be constructed by concatenating "10" + "101" or "101" + "01". Therefore, the answer is 5. However, in the case of the set {"AB", "BA", "ABB"}, there is no string that can be constructed in multiple ways from the building blocks. Therefore, the answer in this case is -1.

How can we solve this problem?

Теги #string

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский pabloskimg 2021-06-10 00:56:10 589 Initial revision (published)