Skip to content

Practice Max Number of K-Sum Pairs

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

Medium#1679
LeetCode Problem

Max Number of K-Sum Pairs

Problem Statement

You are given an integer array nums and an integer k. In one operation, you can pick two numbers from the array whose sum equals k and remove them from the array. Return the maximum number of operations you can perform on the array.

Source: Max Number of K-Sum Pairs on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

Input
nums = [3,1,3,4,3], k = 6
Output
1

Constraints

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

Related LeetCode Problems

Practice more problems similar to Max Number of K-Sum Pairs.

Review your practice with PhantomCodeAI

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