The "Android Unlock Patterns interview question" is a backtracking problem based on the grid used for phone security. You need to find the total number of valid unlock patterns that have a length between m and n. A pattern is valid if:
Google uses the "Android Unlock Patterns coding problem" to test a candidate's ability to implement recursive search with complex constraints. It evaluates "Backtracking interview pattern" skills and the ability to optimize using symmetry (since the pattern counts from corner 1 are the same as corner 3, 7, and 9).
This problem is solved using Backtracking with Symmetry Optimization.
skip[10][10] where skip[i][j] stores the number that must be visited to jump from i to j. For example, skip[1][3] = 2 and skip[1][7] = 4.current to next is valid if next is unvisited AND (skip[current][next] == 0 OR visited[skip[current][next]] == true).Starting at 1, wanting a pattern of length 2:
Symmetry is your best friend in grid-based counting problems. Always ask yourself: "Is the top-left corner essentially the same as the top-right?" This can reduce your computation by 75% and impress your interviewer.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Campus Bikes II | Medium | Solve | |
| Beautiful Arrangement | Medium | Solve | |
| Matchsticks to Square | Medium | Solve | |
| Fair Distribution of Cookies | Medium | Solve | |
| Maximum Compatibility Score Sum | Medium | Solve |