-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Description
LeetCode Username
yashmarathe21
Problem number, title, and link
- Encode and Decode Strings https://leetcode.com/problems/encode-and-decode-strings/
Category of the bug
- Problem description
- Solved examples
- Problem constraints
- Problem hints
- Incorrect or missing "Related Topics"
- Incorrect test Case (Output of test case is incorrect as per the problem statement)
- Missing test Case (Incorrect/Inefficient Code getting accepted because of missing test cases)
- Editorial
- Programming language support
Description of the bug
If there is a testcase with a "\" and any character, the code should not work but this test case is not added in the current list of testcases.
I tried with the delimiter "\$" and the solution got accepted. It worked for all the testcases.
But when I added this test case from my side - ["abc\\$abc"], the code didn't work.
Language used for code
Python
Code used for Submit/Run operation
class Codec:
def encode(self, strs: List[str]) -> str:
"""Encodes a list of strings to a single string.
"""
ans = ""
for i,ele in enumerate(strs):
if i == 0:
ans = ele
continue
ans = ans + "\$" + ele
return ans
def decode(self, s: str) -> List[str]:
"""Decodes a single string to a list of strings.
"""
return s.split("\$")
Expected behavior
For this testcase, "["abc\$abc"]", the code should not have been accepted. But it got accepted.
If this testcase is added, it will result in a more robust check of the solution.
Screenshots
This solution is working for the given testcases and it got accepted as well -


But I found this testcase where it should not work -

Basically, a new testcase needs to be added.