Count Routes Through Four Shop Types
Problem statement
A town has shops.length shops. Shop i has type shops[i], where the four types are numbered from 0 through 3.
The array roads contains undirected roads. Each pair [u, v] connects shops u and v.
Return the number of ordered routes that satisfy all of these rules:
The problem statement continues
ProExamples
Example 1
shops = [0,1,2,3]roads = [[0,1],[1,2],[2,3]]return = 2The valid ordered routes are 0 → 1 → 2 → 3 and 3 → 2 → 1 → 0.
Original screenshot from the interview report
ProFastPrep Pro
Reported in 1 OpenAI interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 1 more worked example, explained
- Guided hints and editorial
- Run your code on real test cases
$8.25/month
$99 billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week