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.
Input
s
: a corrent string of length 2N describing the N rings put on rods
Output
how many points you will get
Examples
Example 1:
Input:
1s = B2R5G2R2
Output: 1
Explanation:
One point for rings put on the second rod.
Try it yourself
Solution
Title
Script
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