Android Unlock Patterns

Given an Android phone's unlock pattern grid (3x3), count the number of valid patterns of length at least m and at most n. A valid pattern:

  • Has unique nodes (no repeats)
  • Cannot skip over an unvisited node unless it's already visited
  • Has length between m and n
Examples
Input: [1,1]
Output: 9
Hints

Android Unlock Patterns

Given an Android phone's unlock pattern grid (3x3), count the number of valid patterns of length at least `m` and at most `n`. A valid pattern: