Official algorithmic problem description and constraints.
You are given a string π of length π consisting of lowercase Latin characters. Find the length of the shortest string π such that several (possibly one) copies of π can be concatenated together to form a string with the same length as π and, at most, one different character.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.