When someone asks you for help solving a problem, ask them, “what have you tried so far?” People asking for help are going to fall into two rough categories.
In the first category are the ones who came to you for help only after they failed to solve their problem on their own. These people are hard-working and earnest. Often they’re smart and capable. Finding out what they’ve tried so far saves you from wasting your time trying things that won’t work.
Then there’s the second category. Those are the people who haven’t put in the effort. Maybe they’re not hard-working, maybe they’re not capable. Those people should not be coming to you for help, but it’s not nice to say so. But if you ask them what they’ve tried so far, and they say “nothing?” Well. That sets you up to politely refused to invest any more time into their problem than they have. Pretty soon they’ll figure out this is what you’re going to ask. Either they’ll try harder, or they’ll stop coming to you. Either way, you’re better off.