Problem · Graph
Order Validator Rule DAG
Learn this problemProblem statement
Process commands over an active rule DAG. ADD|id|field|min|deps adds a rule (use - for no dependencies), REMOVE|id removes and rewires it, and VALIDATE|v0,v1,... checks rules in lexicographically stable topological order. Return ADDED, CYCLE, EXISTS, REMOVED, NOT_FOUND, VALID, or INVALID:id.
Function
runOrderValidator(operations: String[]) → String[]Examples
Example 1
operations = ["ADD|A|0|5|-","ADD|B|1|2|A","VALIDATE|5,2"]return = ["ADDED","ADDED","VALID"]Operation sequence 1 exercises deterministic mutation, cycle, rewiring, or validation behavior.
Example 2
operations = ["ADD|A|0|5|-","VALIDATE|4"]return = ["ADDED","INVALID:A"]Operation sequence 2 exercises deterministic mutation, cycle, rewiring, or validation behavior.
Constraints
1 <= operations.length <= 2000- Rule IDs contain letters and digits only.
- Field indices and minimum values are nonnegative integers.
- Dependencies absent from the active rule set are ignored until their rule is added.