given deciding problem:

input: a CFG G and a word w

question: Does exist a word x in L(G) s.t |x|=|w|

a. The problem is undecidable

b. The problem is decidable but we cannot know if it is in NP

c. The problem is in NP

d. None of the above

Why is the correct answer c ?

What is non-deterministic in this problem? I mean, we can decide if |L(G)| is infinite deterministically, no? and then the answer is yes.

And if |L(G)| is finite, then we can generate each possible word in this CFG and check lengths.

I cant see what is non-deterministic here.