Transform String in Number for Comparison -
i need small problem.
it there possibility (in java or abstract solution) transform arbitrary string integer property, alphabetically ordering work integer?
example: house < tree < zoo in alphabetically order.
i transform strings integer, ordering available. important is, concrete strings not known before. means should unique transformation.
i hope can me.
regards, michael
no, it's not possible. let's have 2 strings represent 1 , 2. can make string fit between them alphabetically e.g.
aa = 1 ab = 2 aaa = ???
if know strings you're dealing have maximum length, possible. example, suppose string has length <= 3. take string abc, , convert each letter number, = 1, b = 2, ..., z = 26. if string less 3 characters long, fill in blanks @ end zeroes. value is:
(a * 27 * 27) + (b * 27) + c
then:
aa = 756 ab = 783 aaa = 757
Comments
Post a Comment