Group all 1s and 2s in a 0/1/2 array with minimum swap cost.
Unlock detailed company stats for this questionUpgrade
Given an array containing 0s, 1s and 2s, arrange the elements so that all 1s and all 2s are grouped together. Swapping a 1 with a 2 costs 1, while swapping with a 0 does not count. Find the minimum cost.
Community answers
No answers contributed by the community yet.
Related questions
Find the minimum cost to go from (0,0) to (n-1,m-1) in a grid of 0s and 1s.Split an array into K contiguous subarrays with minimum total cost.Related courses

Course

Course
Course
