← All problemsSign in

Magic Letters

Consider a string, s, of length n consisting of characters in the set { a, b, c }. We want to know the number of different (i, j, k) triples (where 0 ≤ i , j, k s[i] = "a", s[j] = "b" and s[k] = "c" (j + 1)2 = (i + 1)(k + 1) We consider two triples,(i, j, k) and (x, y, z), to be different if and only if i ≠ x or j ≠ y, or k ≠ z . Given n and s, find and print the number of different (i, j, k) tr

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