Skip to content

Practice Append K Integers With Minimal Sum

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

Medium#2195
LeetCode Problem

Append K Integers With Minimal Sum

Problem Statement

You are given an integer array nums and an integer k. Append k unique positive integers that do not appear in nums to nums such that the resulting total sum is minimum. Return the sum of the k integers appended to nums.

Source: Append K Integers With Minimal Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,4,25,10,25], k = 2
Output
5

# Example 2

Input
nums = [5,6], k = 6
Output
25

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9
1 <= k <= 10^8

Related LeetCode Problems

Practice more problems similar to Append K Integers With Minimal Sum.

Review your practice with PhantomCodeAI

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