# 2834. Find the Minimum Possible Sum of a Beautiful Array

## Problem Statement

<br>

You are given positive integers `n` and `target`.

An array `nums` is **beautiful** if it meets the following conditions:

* `nums.length == n`.
* `nums` consists of pairwise **distinct** **positive** integers.
* There doesn't exist two **distinct** indices, `i` and `j`, in the range `[0, n - 1]`, such that `nums[i] + nums[j] == target`.

Return *the **minimum** possible sum that a beautiful array could have*.

&#x20;

**Example 1:**

<pre><code><strong>Input: n = 2, target = 3
</strong><strong>Output: 4
</strong><strong>Explanation: We can see that nums = [1,3] is beautiful.
</strong>- The array nums has length n = 2.
- The array nums consists of pairwise distinct positive integers.
- There doesn't exist two distinct indices, i and j, with nums[i] + nums[j] == 3.
It can be proven that 4 is the minimum possible sum that a beautiful array could have.
</code></pre>

**Example 2:**

<pre><code><strong>Input: n = 3, target = 3
</strong><strong>Output: 8
</strong><strong>Explanation: We can see that nums = [1,3,4] is beautiful.
</strong>- The array nums has length n = 3.
- The array nums consists of pairwise distinct positive integers.
- There doesn't exist two distinct indices, i and j, with nums[i] + nums[j] == 3.
It can be proven that 8 is the minimum possible sum that a beautiful array could have.
</code></pre>

**Example 3:**

<pre><code><strong>Input: n = 1, target = 1
</strong><strong>Output: 1
</strong><strong>Explanation: We can see, that nums = [1] is beautiful.
</strong></code></pre>

&#x20;

**Constraints:**

* `1 <= n <= 105`
* `1 <= target <= 105`

## Intuition

```
Similar to 2829
```

### Links

<https://leetcode.com/problems/find-the-minimum-possible-sum-of-a-beautiful-array/description/>

### Video Links

### Approach 1:

```
Map
```

{% code title="C++" lineNumbers="true" %}

```cpp
class Solution {
public:
    long long minimumPossibleSum(int n, int target) {
        long long sum = 0, start = 1;
        unordered_map<int,int> mp;

        while(n){
            if( mp.find(start) == mp.end() ){
                sum += start;
                mp[target - start] ++;
                n--;
            }
            
            start++;
        }

        return sum;
    }
};
```

{% endcode %}

### Approach 2:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
```

{% endcode %}

### Approach 3:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
```

{% endcode %}

### Approach 4:

```
```

{% code title="C++" lineNumbers="true" %}

```cpp
```

{% endcode %}

### Similar Problems

###
