Untitled
unknown
java
2 years ago
490 B
3
Indexable
class Solution { long countWays(int n,int k) { //code here. if(n == 0 ) return 0; // in case of no wall // this reprsent if we have only one wall long total = k,same = 0 , diff = k , mod = (long) 1e9 + 7; for(int i = 2 ; i<= n;i++) { same = diff; diff = ((k-1)%mod*(total%mod)); total = (same%mod + diff%mod)%mod; } return total; } }
Editor is loading...
Leave a Comment