class Solution {
public:
vector<int> divingBoard(int shorter, int longer, int k) {
if(k == 0)
{
return {};
}
if(shorter == longer)
{
return {k*shorter};
}
int diff = longer - shorter;
vector<int> res;
for(int i = 0; i < k + 1; i++)
{
res.push_back(k*shorter + i * diff);
}
return res;
}
};
参考链接:https://leetcode-cn.com/problems/diving-board-lcci/solution/tiao-shui-ban-by-leetcode-solution/