LeetCode #231 — Power of Two

David Seek
2 min readJun 8, 2020

Find more useful articles at www.davidseek.com

LeetCode’s challenge of the day on June 8, 2020 (#231) asks us to write a function that determines if the given Integer n is a power of two. In other words: If we multiply the number 2 any amount of times, will we end up with n?

This is a typical dynamic programming problem. We could solve it with recursion. Using a helper function, we would…

--

--