On 06/04/14 19:27, Arup Rakshit wrote:
Suppose, if I have the string 'aababbb', I want to get the output as 'aababb'. I want the output in time complexity O(N) and space complexity O(1). when input string is 'abababa', output should be same as input.
You will need to explain more about what you want to do. Your two examples don't have any obvious link. The first result is 6 characters the second is 7. The first has equal a's and b's the second has differing numbers and doesn't match your subject line. What is the criteria for deciding what the output is? Once we know that we can start worrying about whether the solution is O(N) etc. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
