Sorting an array while moving duplicates to the end?

前端 未结 4 1239
盖世英雄少女心
盖世英雄少女心 2020-12-18 02:16

This was a question in one my friend\'s programming class.

Q. How do you sort an array of ints and then arrange them such that all dupl

4条回答
  •  轮回少年
    2020-12-18 03:09

    a modified merge sort could do the trick: on the last merge pass keep track of the last number you pushed on the front of result array and if the lowest of the next numbers is equal add to the end instead of front

提交回复
热议问题