Tap here to switch tabs
Problem
Submissions

Problem: Max Number of K-Sum Pairs

med
30 min
Try to solve the Max Number of K-Sum Pairs problem.

Statement

Given an integer array nums and an integer k, you may repeatedly choose two distinct elements from nums whose sum equals k and remove both elements from the array. Each such removal counts as one operation.

Return the maximum number of operations you can perform.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Max Number of K-Sum Pairs

med
30 min
Try to solve the Max Number of K-Sum Pairs problem.

Statement

Given an integer array nums and an integer k, you may repeatedly choose two distinct elements from nums whose sum equals k and remove both elements from the array. Each such removal counts as one operation.

Return the maximum number of operations you can perform.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤109\leq 10^9