CSPT01 - EDITORIAL

PROBLEM LINK:

Practice
Contest

Author: Sobhagya Singh Deval
Tester: Yash Chaudhary
Editorialist: Ritik Mittal

DIFFICULTY:

Easy.

PREREQUISITES:

Bitwise operator.

PROBLEM:

Make bitwise and of all array elements be odd.

EXPLANATION:

let the AND be p, the last bit of p must be set. i.e. all the elements in the array should have the last it set, i.e all elements must be odd, if not add one to it.

So the final answer is the count of even elements in the array.

1 Like