|
Hi, yeah, in general I think that you already know the alphabet under
which you are working. So, either you work with ASCII codes or Unicode
codes so as Chitta said you maintain an array with your alphabet sorted
by their codes. Then you start scanning your string and for each
character you see you search for it in your codes array, you mark it as
seen and save the index. If any time along your scanning you see it
again you mark it as repeated. Then you scan your codes array and look
for the smallest index. The whole process takes, if n is the length of
the string: O(nlog(length(codes array))) for the scanning and
O(length(codes_array)) for the answer. You can improve the last bound
by using a Fib heap (for example) as a candidates heap, each time you
see a char is repeated then you delete it from the heap, at the end you
pop the min and you are done... I hope this helps Alfredo Cruz Hi, If the string contains only alphabets then we can maintain an array of 26 characters which tells that the alphabets has occured once or not....if it is already occured .....we can output it directly...more efficient algos are welcome On 8/8/07, JOE11790 <[EMAIL PROTECTED]> wrote: --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" 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/algogeeks -~----------~----~----~----~------~----~------~--~--- |
- [algogeeks] What is the most efficient algorithm to find th... JOE11790
- [algogeeks] Re: What is the most efficient algorithm t... chitta koushik
- [algogeeks] Re: What is the most efficient algorit... Alfredo Cruz
- [algogeeks] Re: What is the most efficient algorit... PicO
