Android Unlock Patterns

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

  • Every node is visited at most once (no repeats).
  • A move may not jump over an unvisited node; jumping over a node is allowed only when that intermediate node has already been visited.
  • The pattern length is between m and n inclusive.
Examples
Input: [1,1]
Output: 9
Hints

Android Unlock Patterns

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