Let $$k\geqslant 1, \quad \Sigma=\{0,1,\#\}$$ I am trying to construct an NFA that accepts the language $L$:
$$L=\{x\#y \mid x,y\in\{0,1\}^k,x\not=y\}$$
Now, here comes the tricky part: it should contain $O(k)$ states.
The best I could think of was $O(k^2)$ and of course that's not enough.
Can you think of something?
I claim that this is impossible: you can't do better than $\Theta(k^2)$.
To show this, let $\mathcal{A}$ be an NFA with state set $Q$ recognizing $L$. We're going to derive a lower bound on its number of states $|Q|$. Without loss of generality, let's suppose that all states of $\mathcal{A}$ are coaccessible; otherwise, we can remove the states of $\mathcal{A}$ that are not, and get a smaller NFA for $L$.
Let $Q_i$ be the set of states that can be reached after reading some word of length $i$. Suppose $q \in Q_i \cap Q_j$. Let $u,v$ be words that bring $\mathcal{A}$ into state $q$, with $|u|=i$ and $|v|=j$. Since $q$ is coaccessible, there is some $w$ that labels a path from $q$ to a final state; then both $uw$ and $vw$ are in $L$ so $|u|+|w| = |v|+|w| = 2k+1$ so $i = |u| = |v| = j$.
The contrapositive of what we just established is that for $i \neq j$, $Q_i$ and $Q_j$ are disjoint. Therefore,
$$|Q| \geq \left| \bigcup_{i=0}^k Q_i \right| \geq \sum_{i=0}^k |Q_i|$$
We now want lower bounds on the $|Q_i|$. Let $P_u$ be the set of states that can be reached after reading $u$. Thus $Q_i = \bigcup_{|u|=i} P_u$, so in particular $P_u \subseteq Q_{|u|}$. Observe that:
Combining these facts we get for every $i \leq k$ that $2^i \leq 2^{|Q_i|}$ and therefore $|Q_i| \geq i$. Plugging this into our earlier inequality, we have
$$|Q| \geq \sum_{i=0}^k i = \frac{k(k+1)}{2} \geq \frac{k^2}{2}$$