def helper(tree: TreeNode, cnt: collections.Counter): if tree: # print(tree.val) cnt[tree.val] += 1 if tree.left or tree.right: helper(tree.left, cnt.copy()) helper(tree.right, cnt.copy()) else: # print(cnt) cur = 0 for k in range(1, 10): if cnt[k] % 2 == 1: cur += 1 if cur <= 1: ret[0] = ret[0] + 1
import random import time from collections import Counter print("0 for heads and 1 for tails") coinVal = random.randint(0, 1) time.sleep(1) memeCountr = Counter.copy(coinVal) print("Tossed", coinVal) time.sleep(1.5) print(memeCountr)