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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Fundamentals
  4. Connecting Towns
  5. Discussions

Connecting Towns

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 153 Discussions, By:

recency

Please Login in order to post a comment

  • roysukalyan_97
    13 hours ago+ 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|
    Permalink
  • imranansari9836
    2 weeks ago+ 0 comments

    Eassy Java : int no_roads=1; for(int i=0;i

    -1|
    Permalink
  • imranansari9836
    2 weeks ago+ 0 comments

    Eassy Java : int no_roads=1; for(int i=0;i

    0|
    Permalink
  • ruben_paparella6
    2 months ago+ 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;
        }
    
    0|
    Permalink
  • MuDai
    3 months ago+ 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 ??

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy