Unordered Map (Hash Table)

Medium STL Containers
Solve in Playground →

Problem Statement

Write a C++ program using `std::unordered_map` for fast key-value lookups.

Input Format

First line: N queries. Next N lines: key-value pairs or lookup queries.

Output Format

Print retrieved values.

Constraints

1 <= N <= 100

Sample Input

3
apple 100
banana 200
apple

Sample Output

100

Explanation

Unordered maps offer average $O(1)$ time complexity for insertions and lookups using hash tables.

Starter Code

#include <iostream>
#include <unordered_map>
#include <string>

int main() {
    int n;
    if (std::cin >> n) {
        std::unordered_map<std::string, int> umap;
        for (int i = 0; i < 2; i++) {
            std::string k;
            int v;
            std::cin >> k >> v;
            umap[k] = v;
        }
        // Write your unordered_map lookup logic here

    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used