FastPrepProcess Graph Rule Validation
Problems/Process Graph Rule Validation

Process Graph Rule Validation

Hadrian logoHadrian● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives a task of validating a directed process graph and three example rules. It does not give the scope of the rules, the path endpoints, what to do with cycles, a portable interface, or the input limits. Our version is about 74% the same as the reported question.

A process system is represented by a directed acyclic graph. Node i has type processTypes.charAt(i), one of A, B, C, or D. Each row [u, v] in edges means that process u can be followed directly by process v.

A complete execution path starts at any node with indegree 0 and ends at any node with outdegree 0. The system is valid only if every complete execution path satisfies all three rules:

  1. The path contains at least one process of type B.
  2. No process of type A appears before a later process of type B on the same path.
  3. Every process of type D has at least one earlier process of type C on the same path.

Return true when every complete execution path is valid; otherwise return false.

Function

isValidProcessSystem(processTypes: String, edges: int[][]) → boolean

Examples

Example 1

processTypes = "BCAD"edges = [[0,1],[1,2],[2,3]]return = true

The only complete path is B -> C -> A -> D. It contains B, its B is before its A, and its D has an earlier C.

Example 2

processTypes = "AB"edges = [[0,1]]return = false

The path contains an A before a later B, which violates the second rule.

Example 3

processTypes = "BCBD"edges = [[0,1],[0,2],[1,3],[2,3]]return = false

The path 0 -> 2 -> 3 reaches D without an earlier C. One invalid complete path makes the whole system invalid.

Constraints

  • 1 <= processTypes.length <= 100000
  • Every character of processTypes is A, B, C, or D.
  • 0 <= edges.length <= 200000
  • Every edge has the form [u, v], where 0 <= u, v < processTypes.length and u != v.
  • The edges are unique and the directed graph is acyclic.

More Hadrian Phone Screen questions

  • Work Order Critical PathPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Best Currency Conversion PathSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Employee Hierarchy Cycle and Depth AnalysisMicrosoft · PHONE SCREENMicrosoft interview questions
  • Minimum Leaf Path Sum over All RootsInfosys · OAInfosys interview questions
  • Sum of Weighted Distances in a TreeGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Decreasing Matrix Path with Limited RelaxationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Tree Node With Maximum BeautyC3.ai · OAC3.ai interview questions
  • Rocket Component CostSpaceX · ONSITE INTERVIEWSpaceX interview questions
  • Maximum Reservoir PowerWells Fargo · OAWells Fargo interview questions
  • Distance Sums to Special Nodes in a Weighted TreeNutanix · ONSITE INTERVIEWNutanix interview questions
All Hadrian interview questionsSee Hadrian hiring insights
Saved
class Solution {
    public boolean isValidProcessSystem(String processTypes, int[][] edges) {
        // Write your solution here
    }
}
Checking account…