find in set of pairs using first value cpp
auto it = std::find_if(st.begin(), st.end(), [](const pair& p ){ return p.first == 1; });
Here is what the above code is Doing:
1. We are using the find_if algorithm to find the first element in the vector that satisfies the condition.
2. The condition is a lambda function that takes a pair
3. The find_if algorithm returns an iterator to the first element that satisfies the condition.
4. If the element is not found, the iterator will be equal to the end iterator.