We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Connecting Towns
Connecting Towns
+ 0 comments JS:
function connectingTowns(n, routes) { // Write your code here if(n<2) return 1; return routes[0]*connectingTowns(n-1,routes.slice(1,n-1)) % 1234567 }
+ 0 comments Eassy Java : int no_roads=1; for(int i=0;i
+ 0 comments Eassy Java : int no_roads=1; for(int i=0;i
+ 0 comments C# solution:
public static int connectingTowns(int n, List<int> routes) { int productOfRoads=1; for(int i=0; i<n-1;i++){ productOfRoads *= routes[i]; productOfRoads %= 1234567; } return productOfRoads; }
+ 1 comment int connectingTowns(int n, vector routes) { int total_routes{1}; for(size_t i = 0 ; i < n-1 ; i++){ total_routes*=routes.at(i) % 1234567; } return total_routes ;
} whats wrong with my code ??
Load more conversations
Sort 153 Discussions, By:
Please Login in order to post a comment