Ap3 1
Ap3 1
Experiment 3.1
continue;
while (!ans.empty() && ans.back() > c &&
count[ans.back()] > 0) {
used[ans.back()] = false;
ans.pop_back();
}
used[c] = true;
ans.push_back(c);
}
return ans;
}
};
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
}
if (third == arr.size())
return {first - 1, second};
return {-1, -1};
}
};
4.Learning Outcomes:
1. Implementing greedy method.
2. Learnt about the properties of greedy algos.
3. Learnt about usage of greedy method at various places.
4. Demonstrate the use of greedy method through problems.