We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var blocker = [][]int{ // 1 2 3 4 5 6 7 8 9 // first column is added so we use 1-9 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // 0 phantom node. as the STARTING point {0, 0, 0, 2, 0, 0, 0, 4, 0, 5}, // 1 {0, 0, 0, 0, 0, 0, 0, 0, 5, 0}, // 2 {0, 2, 0, 0, 0, 0, 0, 5, 0, 6}, // 3 {0, 0, 0, 0, 0, 0, 5, 0, 0, 0}, // 4 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // 5 {0, 0, 0, 0, 5, 0, 0, 0, 0, 0}, // 6 {0, 4, 0, 5, 0, 0, 0, 0, 0, 8}, // 7 {0, 0, 5, 0, 0, 0, 0, 0, 0, 0}, // 8 {0, 5, 0, 6, 0, 0, 0, 8, 0, 0}, // 9 } var M, N int func numberOfPatterns(m, n int) int { M = m N = n var work = make([]bool, 10, 10) return count(work, 0, 0) } func count(work []bool, now int, already int) (res int) { if already >= M && already <= N { res++ } else if already > N { return } for i, tmp := 1, 0; i != 10; i++ { if work[i] { // if already visited continue } tmp = blocker[now][i] if tmp == 0 || work[tmp] { work[i] = true already++ res += count(work, i, already) already-- work[i] = false } } return }
The text was updated successfully, but these errors were encountered:
感谢🙏🏻,这两天我把你这道题也做一下哈。解答代码里面我标明你的代码哈,给大家都一起学习🤝我们一起学习一起交流呀
Sorry, something went wrong.
🤝学习交流!
No branches or pull requests
The text was updated successfully, but these errors were encountered: