Hi While you read the string you just need to keep track of the series & the count and in end do the analysis. for eg p = XXXYY Z = X q = YYXXX
so the actual string would be "XXXYYXYYXXX" keep track of it as : 3X 2Y 1X 2Y 3X from this you can do the analysis that p would be 3X 2Y ie XXXYY and that is repeating in the end as well ie 2Y and 3X so q would be YYXXX and Z would definitely be the middle term ie the X Thanks Ramindar Singh On Thursday, 19 April 2012 23:02:31 UTC+5:30, tech coder wrote: > > determine whether the given string is of form pZq. > p and q can contain only X and Y. > like if p=XXYX then z will be XYXX > for ex XXYXXXYXX is valid > > the limitation is that "you can read only the next character at each > point" . > -- > > Regards > "The Coder" > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/wGGs9ooWV9MJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
