I would suggest that you are struggling because you haven’t tried anything.
So, how would I solve this?
Well, the first thing would be to think it through in pseudo-code. For example, if I was writing a chess program and I wanted to write a function to confirm if the current player is check mated, I might do this:
loop all enemy pieces
if NOT(one of them attacking the king)
loop all possible moves for current player king
if (any of those moves take the king out of check)
loop all current player's pieces (other than king)
if (they have any moves to block the check) OR (they have any moves to capture the checking piece)
This is a really important skill for algorithms. For easy algorithms we often do it instinctually, in our heads, but being able to explicitly sit down and think it through. It will become a valuable tool on the job when you have a complex problem, especially if you are working on a team and want to work out how you want to tackle a problem. It also looks good on an interview if you are given an algorithm problem and you take a second to come up with a plan, especially if they can see/hear your process.