We cast the number to a string to check for the digit while guarding against a leading match. The "cast-to-string for digit-level checks" trick is a Python staple worth pocketing.
We cast the number to a string to check for the digit while guarding against a leading match. The "cast-to-string for digit-level checks" trick is a Python staple worth pocketing.
You are given an integer n and a digit x.
A number is considered valid if:
x, andx.Return true if n is valid, otherwise return false.