🧠 Before you code — what pattern fits?
You are given an integer array nums and an integer k. In one operation, pick two numbers from the array whose sum equals k and remove them. Return the maximum number of operations you can perform.
([1,2,3,4], 5) → 2
([3,1,3,4,3], 6) → 1
🎬 Video explanation · Algorithms Made Easy
Your solution runs against 3 unit tests, including edge and large-value cases.
Loading...
Test console · 3 unit tests
Submit your code to run it against all 3 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.