Apply again next time you are looking for a job, if Amazon and Google really are the sort of companies you want to work for.
Think back on your interviews and figure out what you did wrong, then study up on that.
And next time, prepare very carefully, with a focus on algorithms and data structures. I would use this book, although it's a bit dated now: https://www.amazon.com/Data-Structures-Algorithms-Alfred-Aho...
This one may also be useful: https://www.amazon.com/Programming-Pearls-2nd-Jon-Bentley/dp...
[1] https://www.amazon.com/dp/0201000237