Return key for element that has max int at location [r][c] from a map of 2d vectors

Solution 1:

It is impossible to do this without looking at every 2D array in your map because you need to compare all of them in order to find out which one has the largest integer at your given coordinates. (Using a loop is unavoidable)

Consider a map myMap that has the properties you described, i.e. it has type std::map<std::array<std::array<int>> , char> and it's already filled. Then this code will do what you want:

int max = minimum_int_value;
char myChar = '\0';
for (auto const& entry : myMap) {
    if (entry.first[r][c] > max) {
        max = entry.first[r][c];
        myChar = entry.second;
    }
}