Canonical routing table
A router walks its forwarding table one entry at a time and stops at the first entry whose prefix covers the destination, so the table has to be laid out most specific first. Each entry is written as an IPv4 address, a slash, and a prefix length from 0 to 32, for example 10.4.3.9/16. The four octets carry no leading zeros. The address may carry bits below the prefix length that do not belong to the network, so 10.4.3.9/16 names the same route as 10.4.0.0/16 and has to be printed in that canonical form. Return the canonical entries ordered by prefix length from long to short, and within one length by network address ascending as a number. When two entries reduce to the same canonical route, keep only the one given first. An empty table returns an empty list.
order_route_table(entries: list[str]) → list[str][["10.4.3.9/16","10.4.3.9/24","0.0.0.0/0"]]out["10.4.3.0/24","10.4.0.0/16","0.0.0.0/0"][["192.168.1.5/24","192.168.1.200/24"]]out["192.168.1.0/24"][["10.2.0.0/16","10.1.0.0/16"]]out["10.1.0.0/16","10.2.0.0/16"]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["10.4.3.9/16","10.4.3.9/24","0.0.0.0/0"]]["10.4.3.0/24","10.4.0.0/16","0.0.0.0/0"]not run yetsample[["192.168.1.5/24","192.168.1.200/24"]]["192.168.1.0/24"]not run yetsample[["10.2.0.0/16","10.1.0.0/16"]]["10.1.0.0/16","10.2.0.0/16"]not run yetsample