myronww myronww

Niner since 2004


  • Gary Daniels and Evan Goldring - Mock whiteboard problem

    Actually I think I could get away with performing one less iteration for odd length strings by changing

    while(lptr <= rptr);


    while(lptr < rptr);

    because we would not need to look at the center character for odd length strings.
  • Gary Daniels and Evan Goldring - Mock whiteboard problem

    //This does not handle white space but it should efficiently

    //look for a forward and reverse character pattern. like so "ab c ba"

    bool IsPalendrone(char* ptext)


    bool rtnval = true;

    //Check for NULL or a zero length string

    if((ptext == NULL) || (*ptext == 0))

    return false;

    int textlen = strlen(ptext);

    //Check for the case where ptext is only on char

    if(textlen == 1)

    return rtnval;

    //ptext is more than one car we need to do some


    char* lptr = ptext;

    char* rptr = ptext + (textlen - 1);



    //If we find a case where the character pointed to on

    //the left and right are not equal we can say this is

    //not a palendrone

    if((*lptr) != (*rptr))


    rtnval = false;



    //Move our pointer towards each other



    }while(lptr <= rptr);

    return rtnval;