If you apply for a junior position: no need to do anything. Everything is relative to what kind of a job you want. LeetCode problems are only relevant in FAANG. I've never done LeetCode.
> Will the 4-year gap and my choppy CV be a major hindrance to my hirability?
The short stints don't look great.
> I feel like I have the best chance of getting hired in the kind of roles I used to work at and those are the ones I'm interested in as well but in doing so am I restricting myself to a limited number of positions?
When you specialize in anything, you restrict yourself. However, specializing makes it easier to get through the interview process. There's a bazillion Java developers, but not that many Haskell developers. Haskell shops can't just discard 70% of the applications, they actually can take the time to interview all the people that apply. A great Haskell developer has a way higher chance to get a job than a great Java developer, probably not that much difference for an average one though.
> Is my timing bad?
Does it matter? If you can't get a job right away, keep applying, but find some other way to support yourself in the meantime.