Back to problems

Convert a Hexadecimal Address to Dotted IPv4

Algorithm · Microsoft · Medium

You are given a string text that should represent a 32‑bit hexadecimal address. Parse it and return the corresponding IPv4 address in dotted‑decimal notation, assuming network byte order: the highest‑order (leftmost) byte in the hex string becomes the first decimal octet. If the string is malformed, return the literal string "INVALID". The input must match exactly one of these two forms: Eight consecutive hexadecimal digits (case‑insensitive). The prefix 0x or 0X directly…

Checking your access…