c++指针溢出问题 pointer overflow bugs

leetcode 345题 反转元音字母

代码如下,在本地运行时 所用的测试用例均运行正确

class Solution {
public:
    string reverseVowels(string s) {
        if(s.empty())
            return 0;
        int i = 0 , j = s.size()-1 ;
        const string p="aeiouAEIOU";
        while (i < j){
            if(p.find(s[i]) != s.npos){
                if(p.find(s[j]) != s.npos){
                    swap(s[i],s[j]);
                    i ++; j --;
                }else j --;
                   
            }else i ++;
        }

        return s;

    }
};

leetcode上最后测试用例显示的是空字符串 “”
报错如下:Line 506: Char 9: runtime error: pointer index expression with base 0x000000000000 overflowed to 0xffffffffffffffff (basic_string.h)

但是本地用空字符串测试没问题
求大神详解,万分感谢!!!

在循环里面输出下 i j看看范围是否正确。