Skip to content

Practice Find the Minimum Possible Sum of a Beautiful Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2834
LeetCode Problem

Find the Minimum Possible Sum of a Beautiful Array

Problem Statement

Choose n distinct positive integers such that no two different chosen positions sum to target. Return the smallest possible sum of those integers, modulo 10^9 + 7.

Source: Find the Minimum Possible Sum of a Beautiful Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2, target = 3
Output
4

# Example 2

Input
n = 3, target = 3
Output
8

# Example 3

Input
n = 1, target = 1
Output
1

Constraints

1 <= n <= 10^9
1 <= target <= 10^9

Related LeetCode Problems

Practice more problems similar to Find the Minimum Possible Sum of a Beautiful Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.