
    Write a function that analyzes a customer's transaction pattern code, where each digit represents a spending category threshold and its frequency in the code represents the number of transactions in that category, to determine if the spending behavior is suspicious. The transaction pattern is considered suspicious if any spending category (digit) appears more times than its own value in the pattern code. For example, in pattern code 1124, if category '1' appears twice, it would be flagged as suspicious since 2 > 1.
    

    
def validate(n):
    """
    Write a function that analyzes a customer's transaction pattern code, where each digit represents a spending category threshold and its frequency in the code represents the number of transactions in that category, to determine if the spending behavior is suspicious. The transaction pattern is considered suspicious if any spending category (digit) appears more times than its own value in the pattern code. For example, in pattern code 1124, if category '1' appears twice, it would be flagged as suspicious since 2 > 1.
    

    """
def validate(n):
    """
    Write a function that analyzes a customer's transaction pattern code, where each digit represents a spending category threshold and its frequency in the code represents the number of transactions in that category, to determine if the spending behavior is suspicious. The transaction pattern is considered suspicious if any spending category (digit) appears more times than its own value in the pattern code. For example, in pattern code 1124, if category '1' appears twice, it would be flagged as suspicious since 2 > 1.
    

    """
    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