PiStroke's blog

By PiStroke, history, 3 years ago, In English

Recently, I came across this blog which explains bitwise operations in vector <bool> (c++).

Problem: You are given 10**7 integers in the range [0,10**9], find the number of distinct integers.

In python making a boolean list/array wouldn't help, an integer will occupy at least 24 bits and a bool will occupy 8 bits, the issue is it would lead to MLE, which isn't desirable!

Are there any python alternatives for vector <bool>?

I looked up numPy (even though it's not allowed in online Judge) but it doesn't seem to have one. Bitarray might be of some help, but I believe it's not allowed in Online Judge either.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it