← All problemsSign in

Companion String

Abhishek was given a task by his teacher to find whether the two strings are companion strings or not. Two strings s1 and s2 are said to be companion strings if the number of distinct substrings of s1 and number of distinct substrings of s2 are equal. Also s1 and s2 need not to be of equal length. Given two strings s1 and s2, print “Companion” if s1 and s2 are companion strings, else print “N

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