🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Strings Quiz: all 8 questions

Strings Quiz · Question 5 of 8

How many centers does "expand around center" check for a string of length n?

How many centers does "expand around center" check for a string of length n?

  1. A.n
  2. B.2n − 1
  3. C.n²
  4. D.n / 2
Answer & explanation

Correct answer: 2n − 1

n single-character centers (odd lengths) plus n − 1 gaps between characters (even lengths).

Can you get the rest right without peeking?

Take the timed Strings Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →