Comment

avatar username

There's a $\mathcal{O}(m + q)$ solution for C. Case where $n - k$ is 0, or $n - k > 1$ is handled similarly for yours, however, for $n - k = 1$, we'll do things a bit differently. Since we know that $q$ contains of $k$ distinct integers that should sum up to $n$, but there's one missing integer, the missing integer will be $x = \sum\limits_{i=1}^n i - \sum\limits_{i=1}^k q_i = \frac{n * (n - 1)}{2} - \sum\limits_{i=1}^k q_i$, so the answer will be 1 for $i$ which $a_i = x$ and 0 otherwise

The actual rating of this user is 1951.

Original comment.

Statistics