Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the new year, Geek has decided to go on a road trip in GeekLand with his family. GeekLand has n cities that are connected

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In the new year, Geek has decided to go on a road trip in GeekLand with his family. GeekLand has n cities that are connected by (n1) bi-directional roads. Each road in GeekLand is represented by [a, b, type]. This means that city a and b are connected by a road of 'type'. When type =0 it represents a normal road and when type =1 it represents a highway. Geek considers a trip to be good if it includes - traveling via a highway at least once - stopping at exactly K cities along the way Count the number of good trips possible. Since the answer can be large, return it modulo 109+7. Note that the stops need not be distinct (see the example for better understanding). Example 1: Geek's New Year Trip Accuracy: 50.0% Submissions: 4 Points: 45 Input: n=3 k=2 roads =[ [1,2,1] [2,3,0] ] Output: 4 Explanation: [1,2] : start at 1 , stop at 2 . [1,3] : start at 1 , don't stop at 2 , go directly to 3 . [2,1] : start at 2 , stop at 1 . [3,1] : start at 3 , don't stop at 2 , go directly to 1. Examnle? Your Task: You don't need to read input or print anything. Complete the function countGoodTrips() which takes the number of cities n, number of halts k, and an integer array representing roads. It returns the number of good trips modulo 109+7 Constraints: 0<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago

Question

What are the functions of top management?

Answered: 1 week ago

Question

Bring out the limitations of planning.

Answered: 1 week ago