DEV Community

Discussion on: That Really Tricky "isPandigital" Problem– but in Python

hyftar profile image
Simon Landry • Edited on

All your solutions seem exceedingly complex. I would solve this problem with the following O(n) algorithm:

Create a set with the numbers 1 - N and a second set from the digits in the number given, if both sets are egal then the number is pandigital.

pythonwb profile image
Whiteboarding in Python Author

You're right! I just added this solution to the Github; it looks much cleaner. We might cover sets in a future article. Thank you, sir!