Login

All Problems

Problem title

Difficulty

Avg time to solve

LCA of three Nodes

Easy

20 mins

Sum Of Infinite Array

Moderate

35 mins

Pair Sum

Easy

15 mins

Sum or Product

Easy

15 mins

Yogesh And Primes

Moderate

20 mins

Find Duplicate in Array

Easy

15 mins

Beautiful String

Easy

18 mins

Reverse The Array

Easy

15 mins

Longest Univalue Path

Moderate

10 mins

Sort 0 1 2

Easy

22 mins

Problem

Submissions

297

Avg. time to solve

15 min

Success Rate

80%

Problem Statement

```
Given ‘N’ = 4, ‘Q’ = 1.
Then the answer is 10 because the sum of all integers between 1 and 4 are 1, 2, 3, and 4. Hence 1 + 2 + 3 + 4 is equal to 10.
```

```
The first line of input contains an integer ‘T’ denoting the number of test cases.
Next, ‘T’ lines contain two space-separated integers ‘N’, where ‘N’ is the number given and ‘Q’, denoting the type of query.
```

```
For each test case, You are supposed to return an integer denoting the sum or product of ‘N’ numbers.
```

```
You are not required to print the expected output; it has already been taken care of. Just implement the function.
```

```
1 <= ‘T’ <= 10
1 <= ‘N’ <= 5000
1 <= ‘Q’ <= 2
Time Limit: 1 sec.
```

```
2
4 1
4 2
```

```
10
24
```

```
In the first test case, the answer is 10 because all integers between 1 and 4 are 1, 2, 3, and 4. Hence 1 + 2 + 3 + 4 is equal to 10.
In the second test case, the answer is 25 because all integers between 1 and 4 are 1, 2, 3, and 4. Hence 1 * 2 * 3 * 4 is equal to 24.
```

```
2
5 1
5 2
```

```
15
120
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code