def validate(n):
    counts = [0] * 10

    for ch in str(abs(n)):
        digit = ord(ch) - ord('0')
        counts[digit] += 1

    for digit in range(10):
        if counts[digit] > digit:
            return False

    return True