stl map remove item

#include <iostream>
#include <map>

int main() {
    // Step 1: Create a map
    std::map<int, std::string> myMap = {{1, "One"}, {2, "Two"}, {3, "Three"}};

    // Step 2: Display the original map
    std::cout << "Original Map:" << std::endl;
    for (const auto& pair : myMap) {
        std::cout << pair.first << ": " << pair.second << std::endl;
    }

    // Step 3: Remove an item from the map using erase()
    int keyToRemove = 2;
    auto it = myMap.find(keyToRemove);
    if (it != myMap.end()) {
        myMap.erase(it);
    }

    // Step 4: Display the map after removal
    std::cout << "\nMap after removing key " << keyToRemove << ":" << std::endl;
    for (const auto& pair : myMap) {
        std::cout << pair.first << ": " << pair.second << std::endl;
    }

    return 0;
}