1 / 3
Apr 2020

When i solved this problem by taking vector<int arr(87000008,0),time limit exceeded came but when i used vector<bool arr(87000008,false) it got accepted in 0.76 time.

Also i found on net that in some cases vector is faster than vector.

What’s the reason behind this.
Plz enlighten me.

Which is faster?

  • Vector bool
  • Vector int
  • Depends on the situation.

3voters

Votes are public.

  • created

    Apr '20
  • last reply

    Apr '20
  • 2

    replies

  • 426

    views

  • 2

    users

  • 1

    link

In C++, isn’t a bool one byte? How big is the standard int? Is it two or four bytes?

ya bool is of 1 byte and size of int basically depends on compiler but on mine compiler it’s 4 bytes.