You are viewing a single comment's thread. Return to all comments →
To address this problem, I utilized a dictionary-based approach. There are two distinct conditions to consider:
Under the first condition:
Under the second condition:
def happyLadybugs(b): space = b.count('_') bug = {i:b.count(i) for i in set(b)} if all([bug[i] >= 2 for i in bug if i != "_"]) and space>0 or all([i*2 in b for i in bug if i != "_"]): return 'YES' else: return 'NO'
Seems like cookies are disabled on this browser, please enable them to open this website
Happy Ladybugs
You are viewing a single comment's thread. Return to all comments →
To address this problem, I utilized a dictionary-based approach. There are two distinct conditions to consider:
Under the first condition:
Under the second condition: