Leetcode 2103: Rings and Rods
2 min readJan 21, 2022
--
In this problem, we are given a list of rings going into rods, and we should return how many rods have rings with all the possible colors.
There are
n
rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from0
to9
.
You are given a stringrings
of length2n
that describes then
rings that are placed onto the rods. Every two characters inrings
forms a color-position pair that is used to describe each ring where:
The first character of theith
pair denotes theith
ring's color ('R'
,'G'
,'B'
).
The second character of theith
pair…