← All problemsSign in

Minimum Longest Substring

CodeChefRating 2412Open on judge ↗

You are given a binary string $A$ of length $N$. Rearrange the binary string to form binary strings $S$ and $T$ such that the length of the [longest common substring](https://en.wikipedia.org/wiki/Longest_common_substring_problem) between $S$ and $T$ is **minimum**. Print both strings $S$ and $T$. **Note** that both $S$ and $T$ must be anagrams of $A$ — see the examples below for more clarity.

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start