Re: [algogeeks] first Repeating character in a string

2012-06-08 Thread Mahesh Thakur
lets say we have an array COUNT[256] which is initialized to zero. 1) traverse the string S from 0 to length-1 2) if COUNT[S[i] - '0'] == 0 , increment COUNT[S[i] - '0'] = 1; 3) else print the first repeating character. -Mahesh On Fri, Jun 8, 2012 at 2:26 PM, Anika Jain

Re: [algogeeks] Re: Sorting in O(n)

2012-05-08 Thread Mahesh Thakur
I think if range is till n2, max passes for radix sort will be 3. by subtracting 1 to all the numbers we get the max range to n2-1 and radix sort can be done in 2 passes. but what will happen when if we have a '0' in array and then we subtract 1 to it? On Tue, May 8, 2012 at 9:48 AM, atul anand

Re: [algogeeks] Re: Check if one tree is sub tree of other

2012-03-21 Thread Mahesh Thakur
First Tree: 1 2 3 4 5 67 Inorder traverse will be : 4251637 Second Tree: 6 1 3 Inorder traversal is 163. But they second tree is not subset. let me know if i got the question wrong. On Wed, Mar 21, 2012 at 10:27 AM, shady