“Dr. Watson, Mr. Sherlock Holmes,” said Stamford, introducing us.
“How are you?” he said cordially, gripping my hand with a strength for which I should hardly have given him credit. “You have been in Afghanistan, I perceive.”

Excerpt From
The Complete Sherlock Holmes, Volume I (Barnes & Noble Classics Series)
Arthur Conan Doyle
This material may be protected by copyright.

Hi. This is the definition of the phrase “give someone credit for something”

to believe that someone is good at something or has a particular good quality

Does the definition apply to the bold example?

Thank you.

The dictionary definition you gave is okay, but cumbersome. This is more readily explained as idiomatic, meaning Holmes gripped Watson's hand with strength that one would not expect from someone of such a thin, studious appearance.