HBC52023Jerry,广度优先搜索(BFS),搜索,背包问题,动态规划Shorten IPv6 Address题解

把回忆走一遍 算法基础篇 39 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
You are given an IPv6 address which is a 128-bit binary string. Please determine its shortest representation according to the following rules: Express the address in hexadecimal representa

You are given an IPv6 address which is a 128-bit binary string. Please determine its shortest representation according to the following rules: Express the address in hexadecimal representation and use a colon ':' to split every four hex digits. Every four digits are called a field. For example, '0000:0000:0123:4567:89ab:0000:0000:0000'. Leading zeros in a field can be omitted. For example, the above IPv6 address can be shortened to '0:0:123:4567:89ab:0:0:0'. Consecutive zero fields (with colons near them) consisting of at least two fields can be replaced by a double colon '::'. Besides, no more than one double colon can be used in an address. For example, the above IPv6 address can be shortened to '0:0:123:4567:89ab::' or '::123:4567:89ab:0:0:0', but not '::123:4567:89ab::'. If there are multiple shortest forms of the same length, use the lexicographically (regard the shorten IPv6 address as string) smallest one. If the above rules conflict with rules in the real world, please refer to the rules mentioned in this problem.

HBC52023Jerry,广度优先搜索(BFS),搜索,背包问题,动态规划Shorten IPv6 Address题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断挑战自我,才能突破极限!全网最全C++题库,让您在编程道路上越走越远。

标签: HBC52023Jerry 广度优先搜索(BFS) 搜索 背包问题 动态规划Shorten IPv6 Address题解