Skip to content

Commit ad4b749

Browse files
authored
Update README.md to lc problem: No. 935
1 parent 2dc04df commit ad4b749

File tree

1 file changed

+29
-0
lines changed
  • solution/0900-0999/0935.Knight Dialer

1 file changed

+29
-0
lines changed

solution/0900-0999/0935.Knight Dialer/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,35 @@ func knightDialer(n int) int {
195195
}
196196
```
197197

198+
### **C#**
199+
200+
```cs
201+
public class Solution {
202+
public int KnightDialer(int n) {
203+
if (n == 1) return 10;
204+
int A = 4;
205+
int B = 2;
206+
int C = 2;
207+
int D = 1;
208+
int MOD = (int)1e9 + 7;
209+
for (int i = 0; i < n - 1; i++) {
210+
int tempA = A;
211+
int tempB = B;
212+
int tempC = C;
213+
int tempD = D;
214+
A = ((2 * tempB) % MOD + (2 * tempC) % MOD) % MOD;
215+
B = tempA;
216+
C = (tempA + (2 * tempD) % MOD) % MOD;
217+
D = tempC;
218+
}
219+
220+
int ans = (A + B) % MOD;
221+
ans = (ans + C) % MOD;
222+
return (ans + D) % MOD;
223+
}
224+
}
225+
```
226+
198227
### **...**
199228

200229
```

0 commit comments

Comments
 (0)