We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b72e9f commit 215e5b0Copy full SHA for 215e5b0
Remove repeated digits in a given number.cpp
@@ -0,0 +1,37 @@
1
+
2
+void removerrepeated(ll n)
3
+{
4
+ stack<ll>s;
5
+ s.push(-1);
6
+ ll val;
7
+ while(n)
8
+ {
9
+ val=n%10;
10
11
+ if(val!=s.top())
12
13
+ s.push(val);
14
+ }
15
+ n=n/10;
16
17
+ while(s.top()!=-1)
18
19
+ ll data=s.top();
20
+ cout<<data;
21
+ s.pop();
22
23
+}
24
+int main()
25
26
+ //code
27
+ ll t;
28
+ cin>>t;
29
+ while(t--)
30
31
+ ll n;
32
+ cin>>n;
33
+ removerrepeated(n);
34
+ cout<<endl;
35
36
+ return 0;
37
0 commit comments