Skip to content
LC-2413 Easy LeetCode

2413. Smallest Even Multiple

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 88% Topics: Math, Number Theory
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(1)
# Space: O(1)

# math, bit manipulation
class Solution(object):
    def smallestEvenMultiple(self, n):
        """
        :type n: int
        :rtype: int
        """
        return n<<(n&1)

Solution from kamyu104/LeetCode-Solutions · MIT