Necklace Split
Asked at Google
Reported by the problem's creator, not verified
A necklace is a circular string s made of the letters D and R. A cut c lies between s[c - 1] and s[c], and cut 0 lies between the last letter and the first. For cuts i < j, the two arcs are s[i:j] and s[j:] + s[:i].
Examples
Example 1
Input: s =
DRDROutput:
[0,2]Explanation: Cuts 0 and 2 give arcs
DRandDR; each has oneDand oneR. No smallerithan 0 exists.Example 2
Input: s =
DDDRRROutput:
[-1,-1]Explanation: The necklace has three
Dletters, so no arc can receive exactly half of them. No pair of cuts works.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.