OOP Mini Project: In-Memory Database

Medium Applied C++ OOP Mini Projects
Solve in Playground →

Problem Statement

Implement an OOP in-memory table storage system in C++ with a `Table` class. It should support an `insert(key, value)` method and a `count_prefix(prefix)` method that returns the number of records where the value starts with the given string prefix. Read N rows as key-value pairs (int, string), insert them, filter by value prefix, and print the count.

Input Format

Line 1: integer N. Next N lines: key and val separated by space. Last line: prefix string.

Output Format

Print the number of matching records found.

Constraints

0 <= N <= 50

Sample Input

3
1 apple
2 banana
3 apricot
a

Sample Output

2

Explanation

Records with keys 1 and 3 match the prefix 'a'.

Starter Code

#include <iostream>
#include <vector>
#include <string>

class Table {
public:
    void insert(int key, std::string val) {
        // Write your insertion logic here
    }
    int count_prefix(std::string prefix) {
        // Write your prefix counting logic here
        return 0;
    }
};

int main() {
    // Implement I/O 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