@piyus khanna---
while forming a BST with aaab and removing duplicates if a charcter occur
once ..
so for aaab
first make a node for 'a'.
and ignore next two a's as they are already on the BST. next is 'b'.
make 'b' as root and 'a' on the right side..
and use inorder parsing to get 'ba' as the unique beautiful string.



On Fri, Jul 20, 2012 at 12:22 PM, piyush khanna <piyush_khanna2...@yahoo.com
> wrote:

> @ashish jain :then what for aaab..
>
>   ------------------------------
> *From:* ashish jain <ashishjainco...@gmail.com>
> *To:* algogeeks@googlegroups.com
> *Sent:* Thursday, July 19, 2012 9:48 PM
> *Subject:* Re: [algogeeks] Programming Problem
>
> if from the string s.. a binary search tree (with higher value alphabets
> on the left side of the root and lower value alphabets on the right side of
> root) is formed removing the repeated characters during the formation of he
> BST and then applying inorder technique to get the string s2.
>  String S2 will give the most beautifull unique string producible from s.
>
> ^^ Correct me if wrong!!
>
> On Thu, Jul 19, 2012 at 11:00 AM, gobind hemb <gobind.h...@gmail.com>wrote:
>
> String s is called *unique* if all the characters of s are different.
>
> String s2 is *producible* from string s1, if we can remove some
> characters of s1 to obtain s2.
>
> String s1 is *more beautiful* than string s2 if length of s1 is more than
> length of s2 or they have equal length and s1 is lexicographically greater
> than s2.
>
> Given a string s you have to find the *most beautiful unique* string that
> is producible from s.
>
> *Input:*
>
> First line of input comes a string s having no more than 1,000,000(10^6)
> characters. all the characters of s are lowercase english letters.
>
> *Output:*
>
> Print the most beautiful unique string that is producable from s
>
> *Sample Input:*
>
> babab
>
> *Sample Output:*
>
> ba
>
> *Explanation*
>
> In the above test case all unique strings that are producible from s are
> "ab" and "ba" and "ba" is more beautiful than "ab".
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
>   --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to