Hi,
I used the below logic to solve this:
1) find number of unique chars in the input number. This becomes the base in
which it will have lowest value.
2) assign '1' to first char
3) assign '0' to second unique char that appears in the input num
4) assign 2..base-1 to each unique char that appears in the input in the
increasing order
-- So cats becomes 1023 and zig becomes 102
5) result = 0;
for (i=0;i++;i<length of num){
result = result * base + number representing char[i]
}
output result.
This logic worked fine for small input. But I got "incorrect" response for
large input.
Can someone tell me if this logic is flawed in any sense?
Regards,
KeJo
--
Blog: http://beingkejo.wordpress.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-codejam" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en
-~----------~----~----~----~------~----~------~--~---