Skip to content

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

Description

@Antrikshgwal

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.

Description

When writing C++ solutions in the interactive web editor, lines containing single-quoted character literals (e.g. '$') are truncated during the code submission or compilation phase. This causes standard compilation errors such as:

  • warning: missing terminating ' character
  • error: expected expression

Replacing the character literal with a double-quoted string literal ("$") avoids the issue, suggesting a preprocessing or text-streaming bug in either the frontend editor or the backend code runner.


Steps to Reproduce

  1. Open any C++ problem (e.g. Encode and Decode Strings).
  2. Use a single-quoted character literal as a delimiter, for example:
size_t end = s.find('$');

// OR

while (std::getline(ss, token, '$'))
  1. Click Run Code or Submit.

Expected Behavior

The code should compile successfully, treating '$' as a valid C++ char literal.


Actual Behavior

The submitted code appears to be truncated immediately after the opening single quote, resulting in compilation errors such as:

main.cpp:44:29: warning: missing terminating ' character [-Winvalid-pp-token]
   44 |         size_t end = s.find('
      |                             ^
main.cpp:44:29: error: expected expression
   44 |         size_t end = s.find('
      |                             ^

Environment

  • Platform: NeetCode.io Web Code Editor
  • Language: C++
  • Browser: chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions