Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Rearrange(List<int> v)
- {
- int[] counts = new int[3];
- foreach (var e in v)
- {
- counts[e]++;
- }
- int iNext = 0;
- int limit = counts[0];
- for (; iNext < limit; iNext++)
- {
- v[iNext] = 0;
- }
- limit += counts[1];
- for (; iNext < limit; iNext++)
- {
- v[iNext] = 1;
- }
- for (; iNext < v.Count; iNext++)
- {
- v[iNext] = 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement