NeetCode #801LC-2948MediumGreedy
← Back to All Problems#801 · #2948 · Make Lexicographically Smallest Array by Swapping Elements(交换得到字典序最小的数组)
📌 Problem Statement & Constraints
Given an array
nums and an integer limit, you may swap nums[i] and nums[j] any number of times if |nums[i] - nums[j]| <= limit. Return the lexicographically smallest array obtainable. Constraints: 1 <= nums.length <= 10^5, 1 <= nums[i], limit <= 10^9.🔒
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!