Skip to content

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

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
S556370 opened this issue Jun 7, 2025 · 0 comments
Open

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

S556370 opened this issue Jun 7, 2025 · 0 comments

Comments

@S556370
Copy link

S556370 commented Jun 7, 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.

Instead of having encoded value in decode(), getting it's reference.

class Solution {

public String encode(List<String> strs) {
    StringBuilder sb = new StringBuilder();
    for(String s: strs){
        String len = String.format("%04d",s.length());
        sb.append(len).append(s);
    }  
    System.out.println(sb.toString());      
    return sb.toString();
}

public List<String> decode(String str) {
    List<String> strs = new ArrayList<>();        
    System.out.println(x);
    return strs;
}

}

sout in encode: 0004neet0004code0004love0003you
sout in decode: [Ljava.lang.String;@2d98a335

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