Sugar Mill Batch Production Sequencing
Sugar Mill Batch Production Sequencing
Ravi manages a Maharashtra sugar mill processing different raw material batches. Equipment constraints forbid certain batch sequences (e.g., can't process type B directly after type A). Given N batches with forbidden pairs, find the longest valid production sequence satisfying all constraints. Rule: forbidden pairs are ORDERED: [a,b] forbids type b immediately after type a. Return the longest contiguous run with no forbidden adjacent pair. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.
Approach
Given array of batch types and list of forbidden consecutive pairs, find the longest valid sequence of length N.
Input
Output
More Arrays problems
Browse all coding problems →Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards