// C# Code to count walks from src to dest// with exactly k edges using DPusingSystem;classGfG{// Function to count all walks from src to dest// using exactly k edges with bottom-up DPpublicstaticintcountWalks(int[][]adj,intsrc,intdest,intk){intv=adj.Length;// dp[e][i][j]: number of walks from i to j using e edgesint[,,]dp=newint[k+1,v,v];// Base case: walks from i to j with 0 edgesfor(inti=0;i<v;i++){dp[0,i,i]=1;}// Build the table for all edge counts from 1 to kfor(inte=1;e<=k;e++){for(inti=0;i<v;i++){for(intj=0;j<v;j++){// Consider all intermediate verticesfor(inta=0;a<v;a++){// If there's an edge from i to aif(adj[i][a]==1){dp[e,i,j]+=dp[e-1,a,j];}}}}}returndp[k,src,dest];}staticvoidMain(){int[][]adj=newint[][]{newint[]{0,1,1,1},newint[]{0,0,0,1},newint[]{0,0,0,1},newint[]{0,0,0,0}};intsrc=0,dest=3,k=2;Console.WriteLine(countWalks(adj,src,dest,k));}}