-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
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.
Although the Encode and Decode String problem solution is correct but there is some issue in the compiler
public:
string encode(vector<string>& strs) {
string ans = "";
for(string &s: strs){
ans += to_string(s.size()) + "$" + s;
}
return ans;
}
vector<string> decode(string s) {
vector<string> ans;
int i = 0, n = s.size();
while(i < n){
int j = i;
while(j < n && s[j] != '$'){
j++;
}
int length = stoi(s.substr(i, j-i));
i = j+1;
j = i + length;
ans.push_back(s.substr(i, length));
i = j;
}
return ans;
}
};
Fix this !
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels