Vector modified during iteration
Review this C++ range-for that duplicates flagged items.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1#include <vector>
2
3struct Item { int id; bool flagged; };
4
5void expand(std::vector<Item>& items) {
6 for (const Item& it : items) {
7 if (it.flagged) {
8 items.push_back(Item{ it.id + 1000, false });
9 }
10 }
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.