Question bank › Strings
Dsa Strings Hard

Rotational Substring Match

A string W is a 'rotation' of string V if they have the same length and W can be obtained by shifting V cyclically. Given two strings S and T, find the length of the longest string W such that W is a substring of S and some rotation of W is a substring of T. Input Format: Line 1: String S Line 2: String T Output Format: An integer representing the maximum length. Example: Input: abcdef xbcdae Output: 4 Explanation: 'bcde' is a substring of S. Its rotation 'cdeb' is not in T. However, 'bcda' is a rotation of 'abcd'. 'abcd' is a substring of S, and 'bcda' is a substring of T. Length is 4.

Key concepts

stringscircularitysearch

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.