Find Unique Number

Problem Statement

Given a list or sequence of integer values via the standard input, find the unique number.

Unique number is defined as the number that has all unique digits.

Input

The first line of input contains a sequence of integer values separated by space.

Output

Print the unique number of given integer values.

As is

The boilerplate code is already there to read a sequence of integer values via input from user, in the main() function. Also it calls the findUniqueNumber() function and prints the returned value. Do not edit this code.

To do ✍

findUniqueNumber() has one parameter: arr which is a list of integer values. Write code inside the function body to find the first unique number in the list and return that number.

Example 1

Test input

5522 111 32100 22354 128456 2103

Test output

128456

Explanation

  • 5522 has the digits 5 and 2 occurring twice. Therefore it is not a Unique number.
  • 111 has the digits 1 occurring thrice. Therefore it is not a Unique number.
  • 32100 has the digits 0 occurring thrice. Therefore it is not a Unique number.
  • 22354 has the digits 2 occurring thrice. Therefore it is not a Unique number.
  • 128456 has all unique digits. Therefore it is the Unique number.

Useful References

Python Program

# Complete the following function
# Return the minimum of given integers in nums
def findUniqueNumber(arr):




# Boilerplate code - Do not edit the following
def main():
    arr = [x for x in input().split()]
    print(findUniqueNumber(arr))

if __name__ == "__main__":
    main()

Test case 1

5522 111 32100 22354 128456 2103
128456

Test case 2

12356411
None

Test case 3

122 663 41255 23 0 52155
23
# Complete the following function
# Return the minimum of given integers in nums
def findUniqueNumber(arr):
    for x in arr:
        if len(set(x)) == len(x):
            return x
    return "None"

# Boilerplate code - Do not edit the following
def main():
    arr = [x for x in input().split()]
    print(findUniqueNumber(arr))

if __name__ == "__main__":
    main()
show answer
main.py
⏵︎ Run Tests
Reset
Download
×
Code copied to clipboard successfully 👍