python set based solution
import collections 
from collections import defaultdict
class Solution(object):
    def countPoints(self, rings):
        """
        :type rings: str
        :rtype: int
        """
        ring_slots = defaultdict(set)
        for index  in range(0, len(rings)-1, 2):
            ring_slots[int(rings[index+1])].add(rings[index])
            
        all_color_slots = 0 
        for k, v in ring_slots.items():
            if(len(ring_slots[k])==3):
                all_color_slots = all_color_slots +1 
                
        return all_color_slots
Comments (0)