测试用例太恶心了,受不鸟啊
class Solution {
public static final char NO_NEW_LINE = ''';
public List removeComments(String[] source) {
boolean pending = false;
List result = new ArrayList<>();
for (int i = 0; i < source.length; i++) {
if (!pending) { // 左注释符已闭合
int i1 = source[i].indexOf("//");
if (i1 < 0) i1 = source[i].length();
int i2 = source[i].indexOf("");
if (i2 >= 0) {
source[i] = source[i].substring(i2 + 2);
pending = false;
i--;
}
}
}
return result;
}
public void add(List result, String s) {
if (!result.isEmpty()) {
String tail = result.get(result.size() - 1);
int len = tail.length();
if (tail.charAt(len - 1) == NO_NEW_LINE) { // implicit newline characters can be deleted by block comments
result.set(result.size() - 1, tail.substring(0, len - 1) + s);
return;
}
}
if (s.length() > 0) result.add(s);
}
}



