Algorithm: efficient way to remove duplicate integers from an array

前端 未结 30 2659
离开以前
离开以前 2020-11-22 16:03

I got this problem from an interview with Microsoft.

Given an array of random integers, write an algorithm in C that removes duplicated numbers an

30条回答
  •  暖寄归人
    2020-11-22 16:15

    How about the following?

    int* temp = malloc(sizeof(int)*len);
    int count = 0;
    int x =0;
    int y =0;
    for(x=0;x

    I try to declare a temp array and put the elements into that before copying everything back to the original array.

提交回复
热议问题