STL set is ordered, so we can make use of this property to find the difference between the newly inserted value with previous one and following one. If anyone of them satisfies condition k, then return the day.

```
class Solution {
public:
int kEmptySlots(vector<int>& flowers, int k) {
set<int> pos_set;
pos_set.insert(flowers.front());
for(int i=1; i<flowers.size(); i++){
auto it = pos_set.insert(flowers[i]).first;
if(it != pos_set.begin()){
if(*it - *prev(it)-1 == k){
return i+1;
}
}
if(next(it) != pos_set.end()){
if(*next(it) - *it -1 == k){
return i+1;
}
}
}
return -1;
}
};
```