Sorting an array while moving duplicates to the end?

前端 未结 4 1246
盖世英雄少女心
盖世英雄少女心 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:12

    Use quicksort to sort the array. When implementing the sort you can modify it slightly by adding all duplicates to a seperate duplicate array. When done simply append the duplicate array to the end of the sorted array.

提交回复
热议问题