equal_range in C++

#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    std::vector<int> vec = {1, 2, 2, 3, 3, 3, 4, 5, 6};

    auto range = std::equal_range(vec.begin(), vec.end(), 3);

    std::cout << "Range of values equal to 3: [" << (range.first - vec.begin()) << ", " << (range.second - vec.begin()) << ")" << std::endl;

    return 0;
}
  1. Include Libraries: Include necessary C++ standard libraries.
  2. Main Function: Define the main function.
  3. Create Vector: Define a vector vec containing integers.
  4. equal_range Function: Use std::equal_range to find the range of elements equal to the value 3 within the vector.
  5. Output: Print the indices of the range where elements equal to 3 are found in the vector.
  6. Return: End the main function and return 0 to indicate successful execution.