diff --git a/luku27.tex b/luku27.tex index 65050b5..d422c0f 100644 --- a/luku27.tex +++ b/luku27.tex @@ -404,16 +404,16 @@ and the right endpoint moves two steps to the right. After each step, we update the array \texttt{c}. -If an element $x$ is added to the range, -the value -$\texttt{c}[x]$ increases by one, -and if an element $x$ is removed from the range, -the value $\texttt{c}[x]$ decreases by one. -If after an insertion -$\texttt{c}[x]=1$, -the answer to the query will be increased by one, -and if after a removal $\texttt{c}[x]=0$, -the answer to the query will be decreased by one. +After adding an element $x$, +we increase the value of +$\texttt{c}[x]$ by one +and if $\texttt{c}[x]=1$ after this, +we also increase the answer to the query by one. +In a similar way, after removing an element $x$, +we decrease the value of +$\texttt{c}[x]$ by one +and if $\texttt{c}[x]=0$ after this, +we also decrease the answer to the query by one. In this problem, the time needed to perform each step is $O(1)$, so the total time complexity