Google Online Assessment 2021 (OA) - Rings on Rods

You have 10 rods numbered from 0 to 9. There are three types of rings, red, green and blue, being put on the rods. You get a point for each rod that has a ring of each color on it, i.e. to get a point you need a red ring, green ring and blue ring on one rod.

A ring put on a rod is represented by two characters, the first describes the color of the ring and the second describes which number rod it is on from 0 to 9. For example "R8" means that a red ring is being put on the 8th rod.


  • s: a corrent string of length 2N describing the N rings put on rods


how many points you will get


Example 1:


1s = B2R5G2R2

Output: 1


One point for rings put on the second rod.

Try it yourself




Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

1  >>> a = [1, 2, 3]
2  >>> a[-1]
3  3

Get premium for instant access to all content and solutions