Is it possible to create a NFA that accepts only n*"a" or n*"b" inputs? I'd like to create a NFA that accepts only inputs like &quot;aaaaa&quot;;&quot;a&quot;;&quot;bb&quot;;&quot;bbb&quot;, but not like &quot;aab&quot;;&quot;aabaa&quot;.
Is the even possible? As far as I understand NFA is processing a superspositon of all sub-inputs. So then, if given automaton accepts &quot;a&quot; or &quot;b&quot;, it would always accept &quot;ab&quot; just like it accepts &quot;b&quot;. Is there a way around, am I missing something?

Would it work? After reading n*'a' and then 'b' the automaton leaves accepting state but in the same time it is entering another accepting state.
Yes it is.
Considering regular expression and NFA have the same power (source here), your question amounts to asking if there is such a regular expression.
So the regular expression would be /a*|b*/.
As for a NFA doing such a thing, here is an article describing how to go from regex to NFA.
In the article about regex to NFA, there is a section at the end explaining about metacharacter \$ for end of string. An actual regex for your problem would then be /^(a*|b*)$/ .