benchmarks.wiki / Public workspace

LiveCodeBench / 2811 / determine-the-minimum-sum-of-a-k-avoiding-array

Problem

Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.

contest date

2023-08-20T00:00:00

contest id

weekly-contest-359

difficulty

medium

platform

leetcode

question content

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.
 
Example 1:

Input: n = 5, k = 4
Output: 18
Explanation: Consider the k-avoiding array [1,2,4,5,6], which has a sum of 18.
It can be proven that there is no k-avoiding array with a sum less than 18.

Example 2:

Input: n = 2, k = 6
Output: 3
Explanation: We can construct the array [1,2], which has a sum of 3.
It can be proven that there is no k-avoiding array with a sum less than 3.

 
Constraints:

1 <= n, k <= 50

question title

determine-the-minimum-sum-of-a-k-avoiding-array

starter code

Code

class Solution:
    def minimumSum(self, n: int, k: int) -> int:
        

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See how this is scored Scored by the benchmark’s own harness

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import