Opening your workspace…
Workspace/Coding room
Opening your workspace…
At the North Pole, the elves tap two brass mittens on the kitchen door when they want cocoa. Cook listens for the signal even in the middle of a longer knock. Yesterday the left-right rehearsal got everyone three mugs apiece before breakfast. Today she wants a short signal the elves never tapped yesterday.
Given the rehearsal as a string of L and R, return the shortest nonempty string of taps that never occurs consecutively in it. Break ties in dictionary order, with L before R. For a rehearsal of LLR, return RL. For an empty rehearsal, return L.
"RRR"Output"L"Nobody touched the left mitten, so a single left tap will do.
"LRLL"Output"RR"Both mittens were used. The pairs heard were LR, RL and LL, leaving RR for cocoa.
Check lengths in increasing order. For one length, compare binary encodings of the tap sequences.
function solve(rehearsal) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.