http://www.perlmonks.org?node_id=337447


in reply to Data structure challenge

Trouble is caused by initialisation, so what data structure to use that is initialized in constant time? The answer may be to use simple strings for A and B. The length should be U*log_10(U) so that each group of log_10(U) characters represents an "array element". Initialisation can be done using pack that should be constant time, array access can be simulated using substr which is also constant time.

Just my 2 cents, might be totally wrong, -gjb-