+ 3
Write a program in Java to take input from the user and check whether it is a unique number or not.
A number is said to be unique if the frequency of its every individual digit is one. For example : 1234 is a unique number whereas 1212 is not a unique number becoz the frequency of both 1 and 2 is two.
7 Answers
+ 13
0)if single digit , then unique else
1)take digits in an array
2)arrange the elements of array
3)check if arr [a] ==arr [a+1] ... then break & not a unique no.
+ 3
Thank you very much...
+ 3
It works and I have just posted the program of an unique number...
+ 3
Yeah, that's GREAT.
+ 2
Is it a home work problem? have you tried anything? if so please post the code
+ 2
copy the number into a temp number. Take a Boolean array of size 10. each element represents the presence of a digit. initialize the array with false for all elements. while the temp number is greater than zero take the last digit and update its status in the bool array. divide the temp number by 10. repeat this process till temp is greater than zero.
+ 2
Since you have you tried. Let me show you I would write. https://code.sololearn.com/c2Dw46o11DFU/#java, let me know if you have not understood anything.