Skip to content

Added solution for lc problem 2235 #2008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dsa-problems/leetcode-problems/2200-2299.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const problems = [
"problemName": "2235. Add Two Integers",
"difficulty": "Easy",
"leetCodeLink": "https://leetcode.com/problems/add-two-integers",
"solutionLink": "#"
"solutionLink": "/dsa-solutions/lc-solutions/2200-2299/add-two-integers"
},
{
"problemName": "2236. Root Equals Sum of Children",
Expand Down
88 changes: 88 additions & 0 deletions dsa-solutions/lc-solutions/2200-2299/2235-add-two-integers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
id: add-two-integers
title: Add Two Integers
sidebar_label: 2255 - Add Two Integers
tags:
- Functions
- Arguments
description: Given two integers `num1` and `num2`, return the **sum** of the two integers.
sidebar_position: 2235
---

## Problem Statement
Given two integers `num1` and `num2`, return the **sum** of the two integers.

### Examples

**Example 1:**

```
Input: num1 = 12, num2 = 5
Output: 17
Explination: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.
```

**Example 2:**

```
Input: num1 = -10, num2 = 4
Output: -6
Explination: num1 + num2 = -6, so -6 is returned.
```



### Constraints

- `-100 <= num1, num2 <= 100`

## Solution

#### C++ Implementation

```cpp
class Solution {
public:
int sum(int num1, int num2) {
return num1 + num2;
}
};
```

#### Python Implementation

```python
class Solution:
def sum(self, num1: int, num2: int) -> int:
return num1 + num2
```

#### Java Implementation

```java
class Solution {
public int sum(int num1, int num2) {
return num1 + num2;
}
}
```

#### JavaScript Implementation

```javascript
var sum = function(num1, num2) {
return num1 + num2;
};
```

#### TypeScript Implementation

```typescript
function sum(num1: number, num2: number): number {
return num1 + num2;
};
```

### Conclusion

These implementations handle the addition of two integers and return their sum. The examples provided also show how to use each function. The problem is straightforward and has a constant time complexity of 𝑂(1) for each implementation.
Loading