CT019

Sparse Glyph Array

EasyAcceptance: 0.0%

The Codetikki scribes store massive glyph arrays, but most entries are zero. They need a space-efficient data structure that only stores non-zero values. Implement a sparse array supporting init (with size), set(i, val), and get(i). Input: first line size and number of operations m, then m lines each like "set i v" or "get i". Output: results of get operations, one per line (0 if not set).

Example 1:

Input: 1000000 4 set 5 42 get 5 get 7 set 5 0
Output: 42 0

Example 2:

Input: 10 3 set 0 1 set 9 2 get 0
Output: 1

Constraints:

1 <= size <= 10^9 1 <= m <= 10^5 0 <= i < size -10^9 <= v <= 10^9

Tags:

hash-table design data-structures
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki