DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for LeetCode's Add Two Integers Solution - Java
Piyush Acharya
Piyush Acharya

Posted on • Updated on

LeetCode's Add Two Integers Solution - Java

2235. Add Two Integers

Intuition

I first looked at the inputs that are given to the program. I walked through a simple version of the problem in my head and then in pseudocode.

Approach

I take the 2 inputs, add them together, and return the sum.

Complexity

  • Time complexity:
    O(1)

  • Space complexity:
    O(1)

Code

GitHub: https://github.com/Verisimilitude11/LeetCode-Problems/tree/main/2235.%20Add%20Two%20Integers

class Solution {
    public int sum(int num1, int num2) {
        return num1 + num2;
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

πŸ” If you came here from Google, why not take a look at some of our top posts?