AO
Back

Prefixes Extendable to Exactly K '10' Subsequences

OAAsync OALast reported September 2025Low Frequency

Problem Overview

Given a binary string sequence and an integer k, you may append any number of characters, each '0' or '1', to the end of a string. A string counts as valid if, after appending, the number of "10" subsequences in it is exactly k. (A "10" subsequence is any pair of positions i < j with a '1' at i and a '0' at j.)

Return how many non-empty prefixes of sequence are valid.

Examples (as reported)

sequence = "11",  k = 1  ->  1
sequence = "101", k = 2  ->  2

In the second example, "1" and "10" are valid, but "101" is not: it already has one pair, and appending a '0' adds two more, jumping past 2.

Notes from the reports

  • The first of two problems in a 75-minute online assessment, reported three times in 2025.
  • No input sizes or range for k were reported, and no function name. One candidate's solution recounted every prefix (O(n²)) and passed every test.

What Reports Emphasize

What passers do: One candidate recounted the pairs and 1s for every prefix, then checked pairs == k or k - pairs >= number of 1s; it passed every test case

Why people fail: That same candidate passed every test case, took the assessment on the last day of the window, and was still rejected

Practice

Write your own against 9 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Citadel with friends?

Send them this page. It is free to read, no account needed.

More Citadel Questions

Free preview

Every question in the Citadel catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 62 Citadel questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Citadel · OA · Reported 2× across candidate reports
Is this helpful?