← All problemsSign in

First non-Palindrome

CodeChefRating 2332Open on judge ↗

For the given string S of length N you need to find for each L from 1 to N the first non-palindrome substring of S that has length L. That is, for each L from 1 to N you need to find the smallest positive integer K such that the string S[K, K + L - 1] is not a palindrome. Denote this number by K(L). Here S[i, j] stands for the substring of S composed of its characters in positions i, i + 1, ..., j

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