Looking to create a function that can determine if a number contains consecutive digits:
For example:
- If the input is 11, it will return true
- If the input is 21, it will return false
- If the input is 323, it should return false because even though there are repeated numbers, they are not consecutive
Currently, I am converting the number into an array and iterating through it one by one to check for consecutive digits. However, this approach has a time complexity of O(n). If anyone has alternative solutions with better efficiency, please share.
Thank you!