Skip to content

#1679 - Max Number of K-Sum Pairs

MediumTwo Pointers
Open on LeetCode

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. Return the maximum number of such operations you can perform.

InputOutput
nums = [1,2,3,4], k = 52
nums = [3,1,3,4,3], k = 61
nums = [2,2,2,2], k = 42

Released under the MIT License.