beads describes every bead with two characters: the first is its color ('R', 'G' or 'B') and the second is the peg number (a digit from '0' to '9'). For example, "G3R0" is a green bead on peg 3 and a red bead on peg 0.
Return how many pegs hold beads of all three colors.beads='R5G5B5G2R2' → 1
Peg 5 has all three colors; peg 2 has only a green and a red bead. The answer is 1.
beads='B1B1B1R1' → 0
Peg 1 holds four beads, but none of them is green, so the answer is 0.
beads='G0B9R0B0R9G9' → 2
Both peg 0 and peg 9 carry a red, a green and a blue bead, so the answer is 2.
beads.length = 2 · n, where 1 ≤ n ≤ 100'R', 'G' or 'B''0' to '9'beads='R5G5B5G2R2'
1
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.