I'm no mathematician or leetcode expert and probably don't understand "shortest possible test sequence", but it sounds like this is just bruteforcing 0000-9999. You can't guess what would be closer to the correct solution, so at best I'd propose making a list of choices and randomizing the tries in case you get lucky.
It's different if the keypad gives an indication that one number is correct though, then it'll be 40 tries at most.
Have you read the article we're commenting on? Obviously mathematicians know that n! * k, with k the length of the code, would work. The idea is to superpose the end of a code with the start of the next, so you don't have to test nearly as many combinations.
It's different if the keypad gives an indication that one number is correct though, then it'll be 40 tries at most.