How many number string with absolute difference of every neighboring digits greater than 1

39 Views Asked by At

You are given a string with length 10. Its characters are 0,1,2,...,9 (every number are in the string). How many permutations of the string such that the absolute difference of every two neighboring number are greater than 1?

ex: 1425379680 is correct 1234567890 is wrong because 1 and 2's difference are 1, 2 and 3's difference are 1, etc.

Note: Because it is a string, 0 as a starting number is okay.

*Sorry if my english is bad.