• + 0 comments

    golang solution

    /*
     * Complete the 'connectingTowns' function below.
     *
     * The function is expected to return an INTEGER.
     * The function accepts following parameters:
     *  1. INTEGER n
     *  2. INTEGER_ARRAY routes
     */
    
    func connectingTowns(n int32, routes []int32) int32 {
        mod := int64(1234567)
        
        result := int64(1)
        
        for _, route := range routes {
            result = (result * int64(route)) % mod
        }
        
        return int32(result)
    }