+ 1

Remove all repeated numbers

The user will input a series of digits for example- Input - 15773528157 And the repeated numbers should be removed Output - 157328 Any language is welcomed Happy coding :)

10th Oct 2017, 4:02 PM
Chinmoy
Chinmoy - avatar
6 Respostas
+ 9
You didn't specify if those have to be consecutive numbers, but... UPDATED: https://code.sololearn.com/cVvVJpF45bY8/?ref=app
10th Oct 2017, 4:43 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
my code in c language #include <stdio.h> #include <conio.h> #include <stdlib.h> main() { int a[100],i,j,n; printf("Enter array size:"); scanf("%d",&n); printf("\nEnter %d array element:",n); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("\nOrginal array is:"); for(i=0;i<n;i++) printf("%6d",a[i]); printf("\nNew array is:"); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[j]==a[i]) { a[j]=-98798755;//assign g.value } } } for(i=0;i<n;i++) { if(a[i]!=-98798755) printf("%6d",a[i]); } getch(); }
10th Oct 2017, 4:32 PM
Scooby
Scooby - avatar
+ 2
One liner, works with numbers or text and handles non consecutive letters https://code.sololearn.com/cdhmw4Qty89j/?ref=app
10th Oct 2017, 5:01 PM
VcC
VcC - avatar
+ 1
https://code.sololearn.com/cwU843zL0zf5
20th Dec 2017, 5:27 PM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
11th Oct 2017, 12:48 PM
Siddu Kori
Siddu Kori - avatar
- 2
dup_xx = "".join( [i for i in lst if lst.count(i)>1]) print(dup_xx)
11th Oct 2017, 1:16 PM
VcC
VcC - avatar