Trains the technique from
LeetCode 1768Merge Strings AlternatelyThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A jeweller braids two bead strands onto a single cord. Each strand arrives as text with one letter per bead, listed from the clasp outward: strandA and strandB.
The braid grows one bead at a time. First the clasp-most bead of strandA goes on, then the clasp-most bead of strandB, then the second bead of strandA, then the second bead of strandB, and the turns keep alternating like that. The moment one strand has nothing left to give, every bead still waiting on the other strand goes on in its own order and finishes the braid.
Return the finished braid as text.
Example 1
Both strands hold four beads, so the turns alternate the whole way and neither strand has a leftover.
Example 2
Six beads alternate, then `strandB` is empty and the last bead of `strandA` closes the braid.
Example 3
After six alternating beads `strandA` runs dry, so the two beads still on `strandB` follow in order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def braid_strands(strandA: str, strandB: str) -> str:public String braidStrands(String strandA, String strandB)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.