NeetCode #146LC-2966MediumArrays & Hashing
← Back to All Problems

#146 · #2966 · Divide Array Into Arrays With Max Difference(划分数组并满足最大差限制)

📌 Problem Statement & Constraints

Given an integer array nums and an integer k, divide nums into arrays of exactly 3 elements such that the difference between any two elements in each triple is at most k. Return the resulting 2D array, or an empty array if impossible. Constraints: 1 <= nums.length <= 10^5, nums.length is a multiple of 3, 1 <= k <= 10^5.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!