In most bacterial genomes the leading and lagging strands accumulate mutations at
different rates, leaving an asymmetry in G versus C content. Plotting the running difference along the
genome produces a characteristic V shape whose minimum marks the replication origin (oriC) — the
place where DNA replication begins. This is one of the cleanest examples in all of bioinformatics of a
simple statistic revealing a deep biological structure.
Statement
Define Skew(i) as the number of G minus the number of C in the first i characters
of a genome, with Skew(0) = 0.
Given a genome, find every position i (from 0 to n) at which Skew(i) attains its minimum value.
Print all such positions in increasing order, separated by single spaces, on one line.
Input — read from standard input
| Variable | Type | Description |
|---|---|---|
genome
line 1
|
str |
The genome sequence
1 <= len(genome) <= 5000, uppercase A, C, G, T only
|
These variables are already read for you in the starter code on the right.
Output
str space-separated positions of minimum skew, in increasing order, on one line
Sample Cases
CCTATCGGTGGATTAGCATGTCCCTGTACGTTTCGCCGCGAACTAGTTCACACGGCTTGATGGCAAATGGTTTTTCCGGCGACCGTAATCGTCCACCGAG
53 97
GAGCCACCGCGATA
8 10
Submit also runs your code against 5 hidden test cases. Hidden inputs are never shown — if one fails you'll get its number and a description of the mismatch, not the data.
Constraints
1 <= length(genome) <= 5000- Positions are 0-based prefix lengths: position
imeans the prefix of lengthi Skew(0) = 0is always a candidate and must be considered- If several positions tie for the minimum, print all of them
Further Reading
- Build the skew array in one pass:
+1forG,-1forC,0otherwise. - Track the running minimum and the positions achieving it, or compute the array then scan it.
- Position
0(the empty prefix, skew 0) counts — a genome starting with manyCs will not include it,
but one starting withGmight.