Skip to content

Bug Report for string-encode-and-decode #4037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aaryan1saha opened this issue Apr 12, 2025 · 0 comments
Open

Bug Report for string-encode-and-decode #4037

aaryan1saha opened this issue Apr 12, 2025 · 0 comments

Comments

@aaryan1saha
Copy link

aaryan1saha commented Apr 12, 2025

Bug Report for https://neetcode.io/problems/string-encode-and-decode

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

Test cases does not have any string in which '?' is there so when I am only using a delimiter as '?' the solution is getting ACCEPTED

I have pasted my code here which is getting accepted rather it should fail for cases where '?' is present in string.

string encode(vector& strs) {
string s="";
for(string ch : strs){
s+=ch;
s.push_back('?');
}
return s;
}

vector<string> decode(string s) {
    vector<string>v;
    string str="";
    for(char ch : s){
        if(ch=='?'){
            v.push_back(str);
            str="";
            continue;
        }
        str.push_back(ch);
    }
    if(str!="")
        v.push_back(str);
    return v;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant