Skip to content

Practice Determine the Minimum Sum of a k-avoiding 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#2829
LeetCode Problem

Determine the Minimum Sum of a k-avoiding Array

Problem Statement

You are given two integers, n and k. An array of distinct positive integers is called a k-avoiding array if there does not exist any pair of distinct elements that sum to k. Return the minimum possible sum of a k-avoiding array of length n.

Source: Determine the Minimum Sum of a k-avoiding Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 5, k = 4
Output
18

# Example 2

Input
n = 2, k = 6
Output
3

Constraints

1 <= n, k <= 50

Related LeetCode Problems

Practice more problems similar to Determine the Minimum Sum of a k-avoiding Array.

Review your practice with PhantomCodeAI

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