I’d make a decision based on their appearance, body language, location, seeming intentions, mental state, and whatever other factors I deem relevant in the moment.
If I want to hug them, I’ll hug them. If I don’t, I won’t, and I don’t owe anyone an explanation as to why, beyond, “I don’t want to.”
See, I’m a feminist, and I believe in this thing called “bodily autonomy.” People don't get to touch me unless I say they can -- and I believe one of the most powerful phrases a woman can know (we should al burn it into our brains so we're ready to rip it out, even in the most awkward or unexpected moments) is, "Why are you touching me?"
Or, simply, "STOP touching me."
So, anyway, maybe I decide this is someone I'm comfortable hugging, so I hug them.
Or maybe I chose not to hug them. I’d probably say something like, “How about a friendly wave?" or, "Not today -- but hang in there, dude!”
If the person's going to get upset about that, then they're a motherfucker, and I clearly made the right choice by not hugging them.
So, there you go. The correct answer to the question, "What would you do if a stranger said to you, 'I really need a hug right now.''"
For further reading, I highly recommend:
The Unbreakable Kimmy Schmidt Gif ALL Women Need to See IMMEDIATELY.
Need Proof Women Are Taught to "Be Nice" -- Even When They're In Danger? Prepare to be HORRIFIED.