Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a generic Map type that supports integer keys and allows inserting, retrieving, and deleting key-value pairs.

Hard

Problem Statement

Create a generic Map type that supports integer keys and allows inserting, retrieving, and deleting key-value pairs.

Sample Input

m := NewMap[int, string](); m.Set(1, "Go")

Sample Output

Go

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
package main import "fmt" type Map[K comparable, V any] struct { // Your code here } func NewMap[K comparable, V any]() *Map[K, V] { return &Map[K, V]{} } func main() { m := NewMap[int, string]() m.Set(1, "Go") fmt.Println(m.Get(1)) // Expected output: "Go" }
Log in or sign up to run or submit your code.Log inSign up
Input
m := NewMap[int, string](); m.Set(1, "Go")
Expected Output
Go