leetcode的online judge runtime error是指什么?# JobHunting - 待字闺中
S*e
1 楼
想试一下insert interval的online judge,结果出现
Run Status: Runtime Error
没有具体的错误信息,这种情况是不是说明程序core dump了,而不是test case
failure? 好像没法debug啊。
程序在下面。
class Solution {
public:
vector insert(vector &intervals, Interval
newInterval) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int start, end;
vector::iterator it = intervals.begin();
while (newInterval.start > it->start && newInterval.start > it->end
&& it != intervals.end()) {
++ it;
}
if (newInterval.start < it->start || it == intervals.end()) { //
start from a point between two intervals
start = newInterval.start;
} else {
start = it->start;
}
while (newInterval.end > it->start && newInterval.end > it->end &&
it != intervals.end() ) {
it = intervals.erase(it);
}
if (newInterval.end < it->start || it == intervals.end()){ // end at
a point between two intervals
end = newInterval.end;
} else {
end = it->end;
it = intervals.erase(it);
}
Interval interval(start,end);
intervals.insert(it, interval);
}
};
Run Status: Runtime Error
没有具体的错误信息,这种情况是不是说明程序core dump了,而不是test case
failure? 好像没法debug啊。
程序在下面。
class Solution {
public:
vector
newInterval) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int start, end;
vector
while (newInterval.start > it->start && newInterval.start > it->end
&& it != intervals.end()) {
++ it;
}
if (newInterval.start < it->start || it == intervals.end()) { //
start from a point between two intervals
start = newInterval.start;
} else {
start = it->start;
}
while (newInterval.end > it->start && newInterval.end > it->end &&
it != intervals.end() ) {
it = intervals.erase(it);
}
if (newInterval.end < it->start || it == intervals.end()){ // end at
a point between two intervals
end = newInterval.end;
} else {
end = it->end;
it = intervals.erase(it);
}
Interval interval(start,end);
intervals.insert(it, interval);
}
};