Member-only story
How I Consistently Beat 95% Solutions On LeetCode Without Changing My Algorithm
Tricks I learned from the top competitive programmers
My articles are free to read for everyone. If you don’t have a Medium subscription, read this article by following this link.

At this point, I’ve spent nearly a decade working in software and tackling LeetCode challenges, and trust me, I know how frustrating it can be to craft what you think is a genius solution — only to see 90% of your peers achieve a better runtime than you. Over the years, I’ve come to realize that even though I might not be the wizard of algorithms that some folks are, I definitely do know how to squeeze every ounce of performance from my code. In this short article, I’ll be sharing some really cool GCC optimization pragmas which I picked up over the years from top competitive programming circles.
Disclaimer
This discussion is mainly for GCC and online judges, and the code you write might not be portable across different compilers/platforms. However, it definitely will work on most competitive coding and x86 platforms which aren’t very old. The execution times are non-deterministic and YMMV, however, the optimizations outlined show improvements more-or-less across the board.