Several comments have mentioned memorizing large numbers of Leetcode problems and solutions. That's one way to approach it. Another is to approach it the same way you'd approach chess puzzles. If someone told me I was going to have to pass several Lichess puzzles for some reason, I wouldn't go try to memorize a bazillion puzzles and solutions there.
I have in fact recently been doing a lot of Lichess puzzles, and what happens is I start to notice patterns. For example there have been several puzzles where the other side has just attacked one of my pieces, while I have one of their pieces attacked. So I can take theirs and they take mine, or I can move mine away and they can move theirs away, or I can do something else and let them decide whether to trade or disengage or leave that situation pending.
But wait! For that middle option--mutual disengagement--I see that I can move mine away to a square that gives check. They have to immediately deal with that check so they don't have time to mutually disengage. I'm winning a piece!
And now I've learned a pattern--if someone is depending on some sort of symmetry in a tactical situation that gives them matching moves they must play in response to mine, a forcing move such as check can break that symmetry.
For each puzzle where the answer is not an immediate application of some pattern I've already learned after solving it I step back a few moves before the puzzle position to see how it arose (Lichess puzzles are all drawn from actual games played on the site and include the score up to that point), identify why the move that set up the puzzle was bad, and see if there is some new pattern to learn from it.
I have in fact recently been doing a lot of Lichess puzzles, and what happens is I start to notice patterns. For example there have been several puzzles where the other side has just attacked one of my pieces, while I have one of their pieces attacked. So I can take theirs and they take mine, or I can move mine away and they can move theirs away, or I can do something else and let them decide whether to trade or disengage or leave that situation pending.
But wait! For that middle option--mutual disengagement--I see that I can move mine away to a square that gives check. They have to immediately deal with that check so they don't have time to mutually disengage. I'm winning a piece!
And now I've learned a pattern--if someone is depending on some sort of symmetry in a tactical situation that gives them matching moves they must play in response to mine, a forcing move such as check can break that symmetry.
For each puzzle where the answer is not an immediate application of some pattern I've already learned after solving it I step back a few moves before the puzzle position to see how it arose (Lichess puzzles are all drawn from actual games played on the site and include the score up to that point), identify why the move that set up the puzzle was bad, and see if there is some new pattern to learn from it.