This can be beaten by brute force by memorizing a huge amount of material, but that isn’t the goal. It isn’t like the interviewers think you’ll need to implement their question in your day job.
On the other hand working at FANG encourages developing soft skills (cross team wrangling etc) that no amount of leetcode would teach you.
But very often you have to understand which algorithm to choose. Then you can pick an existing implementation.
In interviews I conduct I gladly allow to read the wikipedia page with a reference implementation (say, for the mentioned Dijkstra algorithm), or pick an implementation from a standard library of a language (say, for a priority queue). What I'm looking for is a conscious and reasonable choice of an approach, and understanding its trade-offs.