One can close as a duplicate and still be helpful and welcoming to a brand new OP.
When faced with this situation, instead of diving straight into the duplicate closure, I'll instead first locate the duplicate, and in particular a specific answer on the dupe and grab its share
link.
Then I manually leave a comment to the effect of:
There's an answer [over here] which seems like it would suit your needs quite well. This is a question that comes up frequently around here.
Then, I close as a duplicate. Other closevoters see the close count, and eventually when the question is closed, the normal duplicate banner goes to the top.
The OP gets a warm and welcoming comment instead of the robotic
possible duplicate of .....
...and the question is closed.
Here is a recent real-world exampleHere is a recent real-world example in which I could point the OP at the target dupe, suggest how their code would be adapted to the existing answer, and then close it with my dupehammer. (visible as long as no one flags & removes the referenced comment)
So to address the question asked here - is it okay to answer? No. There are alternatives. Other less experienced users will probably answer before the closure is complete unless you have a dupehammer, but experienced users who know the landscape and keep a mental catalog of existing answers can navigate this scenario without scaring off new users.