Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一种算法,它将长度为四的字符串映射到四位数字。问题是它必须保持字典顺序。它不需要没有冲突,只是如果 S <= T,F(S) <= F(T)。唯一的附加约束是它应该是满射的:所有数字都必须由某个字符串映射到。
你不能直接将字母映射到数字,一次分组几个来处理字母多于数字的事实吗? {a, b, c} => 1, {d, e, f} => 2等等
{a, b, c} => 1, {d, e, f} => 2