Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

think-cell Software technical test assignment

License

Notifications You must be signed in to change notification settings

veftodii/thinkcell-intervalmap-assignment

Repository files navigation

Task:

Complete the function interval_map::assign() to assign a value to an interval [keyBegin, keyEnd) defined in a variable of type std::map<K, V>. This interval is compressed so the map contains only the first element of it. If keyBegin >= keyEnd then this designates an empty interval and assign must do nothing.

Note

This task description is approximate because the original one wasn't saved.

Sample input:

interval_map<int, char> m('A'); // Contains the field std::map<K, V> m_map;
// Initialize the intervals
m.m_map[1] = 'B';
m.m_map[3] = 'A';
m.m_map[6] = 'C';
m.m_map[10] = 'A';

// Assign a new value to an interval
m.assign(1, 3, 'B');
printMap(m.m_map);
m.assign(1, 6, 'D');
printMap(m.m_map);

Sample output:

{{1 : B} {3 : A} {6 : C} {10 : A}}
{{1 : D} {6 : C} {10 : A}}

About

think-cell Software technical test assignment

Topics

Resources

License

Stars

Watchers

Forks

Languages