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.
Bug Description: The system is not accepting my code for the below input:
dummy_input=["",""]
Your Output: []
Expected output: ["",""]
But my code is working fine for this input.
Here is my solution:
class Solution{
public static void main(String[] args){
List input = new ArrayList<>();
input.add("","");
System.out.println("Input: " + input);
String encode = encode(input);
System.out.println("Encoded: " + encode);
List decode = decode(encode);
System.out.println("Decoded: " + decode);
}
public static String encode(List strs) {
StringBuilder strBuilder = new StringBuilder();
for(int i = 0; i < strs.size(); i++){
strBuilder.append(strs.get(i));
if(i == (strs.size()-1)){
//do nothing
}else{
strBuilder.append("ð");
}
}
return strBuilder.toString();
}
public static List<String> decode(String str) {
String[] arr = str.split("ð");
List<String> result = new ArrayList<>();
Arrays.stream(arr).map(result::add).collect(Collectors.toList());
return result;
}
}
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.
Bug Description: The system is not accepting my code for the below input:
dummy_input=["",""]
Your Output: []
Expected output: ["",""]
But my code is working fine for this input.
Here is my solution:
class Solution{
public static void main(String[] args){
List input = new ArrayList<>();
input.add("","");
System.out.println("Input: " + input);
String encode = encode(input);
System.out.println("Encoded: " + encode);
List decode = decode(encode);
System.out.println("Decoded: " + decode);
}
public static String encode(List strs) {
}