Back to problems

Necklace Cut into Two Halves with Equal D/R Counts

Algorithm · Google · Medium

Requirements You receive a circular string s whose characters come from {D, R}, with D == R . Return two cut positions—or indicate that a single cut is enough—so the resulting two pieces contain equal numbers of each letter. Under this guarantee, no more than two cuts are required; derive and justify that bound. Examples

Checking your access…