
    Write a function that takes a route identifier number and validates if the occurrence of each traffic density level (represented by digits 0-9) across route segments does not exceed the actual density value itself, ensuring optimal fleet distribution along the route. For example, in a route identifier, the digit 3 should not appear more than 3 times, and digit 1 should not appear more than once.
    

    
def validate(n):
    """
    Write a function that takes a route identifier number and validates if the occurrence of each traffic density level (represented by digits 0-9) across route segments does not exceed the actual density value itself, ensuring optimal fleet distribution along the route. For example, in a route identifier, the digit 3 should not appear more than 3 times, and digit 1 should not appear more than once.
    

    """
def validate(n):
    """
    Write a function that takes a route identifier number and validates if the occurrence of each traffic density level (represented by digits 0-9) across route segments does not exceed the actual density value itself, ensuring optimal fleet distribution along the route. For example, in a route identifier, the digit 3 should not appear more than 3 times, and digit 1 should not appear more than once.
    

    """
    for i in range(10):
        temp = n
        count = 0
        while temp:
            if temp % 10 == i:
                count += 1
            if count > i:
                return False
            temp //= 10
    return True