Validate IPv4 Address
In a world where networks and connections are everywhere, validating IP addresses becomes a common task. An IP address is a label assigned to a device connected to a computer network. The most common version of an IP address is IPv4. Your task is to create a program that validates IPv4 addresses.
A valid IPv4 address consists of four numbers separated by periods. Each number should not exceed 255.
The input contains a single line with a string
s
that represents the potential IP address.The program should output
VALID
if the provided string is a valid IPv4 address, and INVALID
otherwise.Input | Output |
192.168.1.1 | VALID |
256.60.124.136 | INVALID |
Note: The numbers in an IPv4 address cannot have leading zeros. For example, the address "192.168.01.1" is considered INVALID.
Constraints
Time limit: 0.2 seconds
Memory limit: 512 MB
Output limit: 1 MB