Meta Data#
Difficulty: easy First Attempt: 2025-12-17
- Submissions: Accepted (Python) → Compile Error (C++) → Accepted (C++)
Approach#
Return num1 + num2. I used this one to practice C++ syntax.
My Attempts#
The first C++ version, return num1 + num2, was missing a semicolon: Compile Error.
Solution#
class Solution:
def sum(self, num1: int, num2: int) -> int:
return num1 + num2
Complexity#
Time O(1), space O(1).
Mistakes to Avoid#
- Switching from Python to C++, statements need a trailing semicolon.
Interview Explanation#
Return the sum directly. The value range is tiny, so there is no overflow. Time O(1).
