Tap here to switch tabs
Problem
Submissions

Problem: Rings and Rods

med
30 min
Try to solve the Rings and Rods problem.

Statement

There are nn rings placed onto 1010 rods labeled from '0' to '9'. You are given a string rings of length 2⋅n2 \cdot n that describes the rings placed on the rods.

The string rings is formatted in 22 character pairs such that:
The character at rings[2⋅i2 \cdot i] describes the color of the ii-th ring, which is either 'R' (red), 'G' (green), or 'B' (blue).
The character at rings[2⋅i+12 \cdot i + 1] describes the rod label where the ii-th ring is placed, which is between '0' and '9'.

Return the total number of rods that have all 33 colors of rings placed on them.

Constraints:

  • rings.length ==2⋅n== 2 \cdot n

  • 1≤n≤1001 \leq n \leq 100

  • rings[i] where i is even is either 'R', 'G', or 'B' (00 indexed).

  • rings[i] where i is odd is a digit from '0' to '9' (00 indexed).

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Rings and Rods

med
30 min
Try to solve the Rings and Rods problem.

Statement

There are nn rings placed onto 1010 rods labeled from '0' to '9'. You are given a string rings of length 2⋅n2 \cdot n that describes the rings placed on the rods.

The string rings is formatted in 22 character pairs such that:
The character at rings[2⋅i2 \cdot i] describes the color of the ii-th ring, which is either 'R' (red), 'G' (green), or 'B' (blue).
The character at rings[2⋅i+12 \cdot i + 1] describes the rod label where the ii-th ring is placed, which is between '0' and '9'.

Return the total number of rods that have all 33 colors of rings placed on them.

Constraints:

  • rings.length ==2⋅n== 2 \cdot n

  • 1≤n≤1001 \leq n \leq 100

  • rings[i] where i is even is either 'R', 'G', or 'B' (00 indexed).

  • rings[i] where i is odd is a digit from '0' to '9' (00 indexed).