Android Unlock Patterns
Posted keepshuatishuati
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Unlock Patterns相关的知识,希望对你有一定的参考价值。
public class Solution { private boolean[][] visited = new boolean[3][3]; private int m; private int n; public int numberOfPatterns(int m, int n) { if (n == 0 || m > n) { return 0; } int result = 0; this.m = m; this.n = n; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { visited[i][j] = true; result += getPattern(i, j, 1); visited[i][j] = false; } } return result; } private int getPattern(int x, int y, int level) { if (level > n) { return 0; } int result = level >= m ? 1 : 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (visited[i][j] || x == i && Math.abs(y - j) == 2 && !visited[i][1] || y == j && Math.abs(x - i) == 2 && !visited[1][j] || Math.abs(x - i) == 2 && Math.abs(y - j) == 2 && !visited[1][1]) { continue; } visited[i][j] = true; result += getPattern(i, j, level + 1); visited[i][j] = false; } } return result; } }
1. 3x3 pattern board. Do not mess it up.
2. pattern counting start from 1, not 0
以上是关于Android Unlock Patterns的主要内容,如果未能解决你的问题,请参考以下文章
LC 351. Android Unlock Patterns
[LeetCode] Android Unlock Patterns 安卓解锁模式
appium+python解决每次运行代码都提示安装Unlock以及AppiumSetting的问题