Remove duplicates from Array without using Hash Table

后端 未结 7 1700
终归单人心
终归单人心 2020-12-15 14:37

i have an array which might contain duplicate elements(more than two duplicates of an element). I wonder if it\'s possible to find and remove the duplicates in the array:

7条回答
  •  忘掉有多难
    2020-12-15 15:40

    No restrictions on complexity.

    So this is a piece of cake.

    // A[1], A[2], A[3], ... A[i], ... A[n]
    
    // O(n^2)
    for(i=2; i<=n; i++)
    {
        duplicate = false;
        for(j=1; j

提交回复
热议问题