#3551
Minimum Swaps to Sort by Digit Sum
specialist · 870 · lc medium +31 · 50.5% accepted · 143 likes · top 38%
Description
Sort the distinct positive integer array nums by digit sum (ascending), breaking ties by value (smaller first). Return the minimum number of adjacent-position swaps needed to achieve this ordering.
Code
1
2
3