bool interleaved(char *s1, char *s2, char *s3) { // Base case, all strings are empty return (!s1[0] && !s2[0] && !s3[0]) ||
// First character of s1 is next in s3 (s1[0] && (s1[0] == s3[0]) && interleaved(s1+1,s2,s3+1)) || // First character of s2 is next in s3 (s2[0] && (s2[0] == s3[0]) && interleaved(s1,s2+1,s3+1)); } On May 19, 1:33 pm, Piyush Sinha <ecstasy.piy...@gmail.com> wrote: > Design an algorithm to find whether a given string is formed by the > interleaving of two given strings or not. e.g. s1= aabccabc s2= dbbabc s3= > aabdbbccababcc Given s1,s2,s3 design an efficient algorithm to find whether > s3 is formed from the interleaving of s1 and s2 > > -- > *Piyush Sinha* > *IIIT, Allahabad* > *+91-8792136657* > *+91-7483122727* > *https://www.facebook.com/profile.php?id=100000655377926* -- 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.