+ 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 :)
6 ответов
+ 9
You didn't specify if those have to be consecutive numbers, but...
UPDATED:
https://code.sololearn.com/cVvVJpF45bY8/?ref=app
+ 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();
}
+ 2
One liner, works with numbers or text and handles non consecutive letters https://code.sololearn.com/cdhmw4Qty89j/?ref=app
+ 1
https://code.sololearn.com/cwU843zL0zf5
0
here is my code in python...
https://code.sololearn.com/c31u8NtXM5iS/?ref=app
- 2
dup_xx = "".join(
[i for i in lst if lst.count(i)>1])
print(dup_xx)