File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
solution/0900-0999/0935.Knight Dialer Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,35 @@ func knightDialer(n int) int {
176
176
}
177
177
```
178
178
179
+ ### ** C#**
180
+
181
+ ``` cs
182
+ public class Solution {
183
+ public int KnightDialer (int n ) {
184
+ if (n == 1 ) return 10 ;
185
+ int A = 4 ;
186
+ int B = 2 ;
187
+ int C = 2 ;
188
+ int D = 1 ;
189
+ int MOD = (int )1 e 9 + 7 ;
190
+ for (int i = 0 ; i < n - 1 ; i ++ ) {
191
+ int tempA = A ;
192
+ int tempB = B ;
193
+ int tempC = C ;
194
+ int tempD = D ;
195
+ A = ((2 * tempB ) % MOD + (2 * tempC ) % MOD ) % MOD ;
196
+ B = tempA ;
197
+ C = (tempA + (2 * tempD ) % MOD ) % MOD ;
198
+ D = tempC ;
199
+ }
200
+
201
+ int ans = (A + B ) % MOD ;
202
+ ans = (ans + C ) % MOD ;
203
+ return (ans + D ) % MOD ;
204
+ }
205
+ }
206
+ ```
207
+
179
208
### ** ...**
180
209
181
210
```
You can’t perform that action at this time.
0 commit comments