@aditya : I am wondering how many times 7 has occurred. Is it 1? Or is
it 0?

Please take a moment before posting your solution, and think whether
it is write or wrong!

On Jul 6, 12:11 am, aditya kumar <[email protected]> wrote:
> Q3. ans:70000000 i guess this is also a correct answer and no unique soln as
> such
>
> On Wed, Jul 6, 2011 at 12:37 AM, aditya kumar
> <[email protected]>wrote:
>
>
>
>
>
>
>
> >  boolean palindromeCheck(String string)
> > {
> >  len=string.length();
> > if((string.length()>1))
> > {
> >  if((string.charAt(0)==string.charAt(len-1)))
> > {
> > str="";
> >  str=str+string.substring(1,(len-1));
> > palindromeCheck(str);
> > }
> >  else
> > {
> >  flag=false;
> > }
> >     }
> >  return flag;
> > }
>
> > THis also works fine if you dont want to use pointer
>
> > On Tue, Jul 5, 2011 at 9:37 PM, Azhar Hussain <[email protected]> wrote:
>
> >> For Q4: I think this is the optimal code
>
> >> int recurPalin(char *start, char *end)
> >> {
> >>     if (end < start)
> >>         return true;
>
> >>     if (*start != *end)
> >>         return false;
>
> >>     return recurPalin(start+1, end-1);
> >> }
>
> >> -
> >> Azhar.
>
> >> On Tue, Jul 5, 2011 at 12:21 PM, vikas <[email protected]> wrote:
>
> >>> My program for Q4.
> >>>  // recursively find if a given string is palindrome
> >>>         bool IsPalindrome(string s, int start, int start2, bool flag)
> >>>         {
> >>>             bool flag1 = flag;
> >>>             if (start >= 0 && start2 < (s.Length))
> >>>             {
> >>>                 char c1 = s[start];
> >>>                 char c2 = s[start2];
> >>>                 if (c1.Equals(c2))
> >>>                 {
> >>>                     if (start == 0 && start2 == s.Length - 1) { flag =
> >>> true; }
> >>>                     if (IsPalindrome(s, start - 1, start2 + 1, flag))
> >>>                     {
> >>>                         flag1 = true;
> >>>                     }
> >>>                 }
> >>>             }
> >>>             return flag1;
> >>>         }
>
> >>> while calling
> >>>            if (s.Length % 2 != 0)
> >>>             {
> >>>                 p.IsPalindrome(s, s.Length / 2 - 1, s.Length / 2 + 1,
> >>> false);
> >>>             }
> >>>             else
> >>>             {
> >>>                 p.IsPalindrome(s, s.Length / 2 - 1, s.Length / 2, false);
>
> >>>             }
>
> >>> --
> >>> 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/-/I6SVTB0o-uUJ.
>
> >>> 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.
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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.

Reply via email to