Write a program to check if an entered array of 10 numbers is in sequence from 0 to 9, and then optimize your solution for time and space complexity.