Skip to main content
Android Unlock Patterns | AlgoCracked
AlgoCracked
ProblemsAndroid Unlock Patterns
Medium51.0% acceptance
Dynamic ProgrammingBacktracking

Android Unlock Patterns

Android phones unlock with a pattern drawn over a 3×3 grid of keys numbered 1–9 (1,2,3 on the top row, 4,5,6 in the middle, 7,8,9 on the bottom). A valid pattern visits between m and n keys (inclusive) , never revisits a key, and obeys one rule: to move directly between two keys, any key lying strictly on the straight line between them must already have been visited . For example a move from 1 to 3 is only allowed if 2 was visited first; a move from 1 to 9 needs 5 first. Return the total number of distinct valid patterns. Input format Input is [m, n] , e.g. [1,2] .

Loading workspace…