← All problemsSign in

And Sort

CodeChefRating 3152Open on judge ↗

For a given array $B$ of length $M$, a non-negative integer $X$ is said to be **good** if: - The array $C$ of length $M$ defined as $C_i = B_i\space \&\space X$ is sorted in **non-decreasing** order, where $\&$ denotes the [Bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) operation. --- Given an array $A$ of length $N$, where $0 \leq A_i \leq N$ holds true for all $i$, count th

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start