Preparing for the interviews is hard, and takes a lot of time. Even if you are already a good engineer, to learn to solve interview problems you may still need to practice several hours a day for months.
Investing so much time and effort is not easy. So how do you stay motivated? Below are some advice and strategies that may help.
Remember how much engineers at the top companies are paid. In general, if you are a software engineer at a good company, you will earn at least 100000$ in the US, and at least 50000-70000$ in Europe.
Why do you want to pass interviews and to get to the top companies? Best engineering in the world? Free food? Great culture and smart colleagues? Cool office? Good experience in the resume?
Remembering these can help you stay motivated. You may also watch some videos on YouTube for extra motivation.
Preparing for the interviews is a marathon, not a sprint. You are much better preparing for 1-2 hours every day, than 12 hours a day once in a while.
Find your system for preparation. You may keep the log of your everyday preparation, track your progress, and outline your future goals there. For that, you can try Notion, Trello, Bullet Journal, or Quiver. See what works for you.
Preparation log will help you build a habit, and will also help later in reviewing the material you have studied.
Right before your interviews, I recommend spending 2-3 months in the mode of intensive practice. Focus on the preparation, and make it your top priority. Quit social media. Travel and hang out with friends much less, and ignore most of the other "important" errands. If you are preparing for the interviews, why not give it your best shot?
Having a friend who is also preparing for the interviews or passed them recently can also help a lot. You can discuss your progress with him or her, or just motivate each other.
Set yourself a deadline. It may be something like "I will prepare for two months, and then apply". It may also be a good idea to apply earlier and schedule your interviews for a couple of months in the future – this will boost your motivation to prepare.
You may miss your deadline, but it's still much better than having no deadlines at all, and simply preparing for "sometime in the future" (this "sometime" never comes).
Read a chapter or two in Coders at Work for an inspiration.
Try starting to use some system, and outline some future goals and tasks there. For example, you may try one of the following apps and see what works for you: Notion, Trello, or Quiver.