g***j 发帖数: 1275 | 1 在排序的时候,用到这个比较的function来排序这些intervals
sort(intervals.begin(), intervals.end(), isLess);
因为是按照x的坐标来比较的,为啥这里必须用 < 而不是<=,为啥用<= 就会错呢?
bool isLess(const Interval a, const Interval b) {
return a.start < b.start; // couldn't use <=
}
这是算法的问题,还是c++的问题? |
|
R*****i 发帖数: 2126 | 2 没做过leetcode的题,我胡言两句。
没觉得用<=是错的(在某些情况下可能是必须的),只是觉得不好。第一,函数名字叫
isLess,结果你用了<=,这个不匹配函数名,不好,第二,C++的sort一般用的是
introsort方法吧?如果后一个等于前一个的情况下,还要swap的话,速度肯定比不
swap慢。所以从速度上看,也尽量不swap的好。 |
|
v****e 发帖数: 19471 | 3 - The market is in a vulnerable state and bearish is the mid-term picture.
But it will not simply roll over
and dive straight down this time, as the mood in market isless pessimistic
and panic than last year.
- Now everyone sees the signal that the bigger bear trend may have resumed
power, it's time for a
bounce.
- Next week, DJI may bounce from 12400 level to 12700-12800 level. NAZ may
see 2410 first then
bounce to 2460--2470 . For S&P, it may revisit 1400 before drop again. $VIX
may revisit 18 |
|