will this work 4 axxbxba chars r a,b in this str Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652
On Fri, Jun 17, 2011 at 11:47 PM, sunny agrawal <sunny816.i...@gmail.com>wrote: > Try this: > > say i is the index of the first occurrence of the first character > say j is the index of the first occurrence of the second character > say n is length of array > int Min = n+1; > > while(i < n && j < n){ > int Min = min(Min, abs(i-j)) > if(i < j){ > find next occurrence of first character > } > else{ > find next occurrence of second character > } > } > > On 6/17/11, Harshal <hc4...@gmail.com> wrote: > > Given a character array with a set of characters, there might be > repetitions > > as well, given two characters, you should give the minimum distance > between > > these two characters in the whole array. O(n) solution is required. > > > > -- > > Harshal Choudhary, > > III Year B.Tech CSE, > > NIT Surathkal, Karnataka, India. > > > > -- > > 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. > > > > > > > -- > Sunny Aggrawal > B-Tech IV year,CSI > Indian Institute Of Technology,Roorkee > > -- > 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.