Anybody realize the potential overflow in your C++ code?

  • 0

    I've seen manybool isMatch(const char *s, const char *p) version in this discuss, maybe leetcode use this c-language style before. In this version, it's ok when we check ''--if (*(p + 1) != '*'), because there is '\0'. But what it can be if we use string type-- bool isMatch(string s, string p)? generally, string give us space more than we need, or equal. the redundant space is initialized to '\0', but when they equals, can we still use code like this: if(p[sp+1] != '')? or this situation just not exist?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.