FastPrepRule References: Validity and Eligibility
Problems/Rule References: Validity and Eligibility

Rule References: Validity and Eligibility

Plaid logoPlaid● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report explicitly distinguishes structural reference validity from all-pass eligibility, a core match of about 95%. Unique case-sensitive names, an empty-input convention and bounded token sizes make the practice contract precise.

Each row of rules is [name, result]. A result is the terminal pass, the terminal fail, or a rule name to follow.

Implement the following two predicates over the complete input:

  • isValid(rules) is true exactly when every result is pass, fail, or a name defined in rules. This checks reference existence only: a self-reference or a closed cycle of defined names is still structurally valid.
  • isEligible(rules) is true exactly when the chain starting from every rule eventually reaches pass. A chain ending at fail, referring to a missing name, or repeating a name without reaching a terminal makes the complete input ineligible.

The callable adapter validateRuleChains(rules) returns the two Boolean decisions in the fixed order [isValid(rules), isEligible(rules)]. Rule order does not affect the result, and a reference may point to a later row.

For this exercise, assume names are unique and case-sensitive, and the terminals are exactly lowercase pass and fail. For this exercise, assume an empty input returns [true,true]. In particular, [["A","B"],["B","A"]] returns [true,false]: its references exist, but neither rule ever reaches pass.

Function

validateRuleChains(rules: String[][]) → boolean[]

Examples

Example 1

rules = [["rule_A","pass"],["rule_B","rule_C"],["rule_C","pass"]]return = [true,true]

Every result is a terminal or a defined rule name. The chains are rule_A -> pass, rule_B -> rule_C -> pass, and rule_C -> pass. All three reach pass, so both predicates are true.

Example 2

rules = [["rule_A","pass"],["rule_B","rule_C"],["rule_C","fail"]]return = [true,false]

All references exist, so isValid is true. Both rule_B and rule_C reach fail, while rule_A reaches pass. Since not every rule passes, isEligible is false.

Example 3

rules = [["rule_A","rule_X"]]return = [false,false]

rule_X is not defined, so isValid is false. The only chain cannot reach pass, so isEligible is also false.

Constraints

  • For this exercise, assume 0 <= rules.length <= 200.
  • Every row contains exactly two strings.
  • For this exercise, assume each string has between 1 and 32 ASCII letters, digits, or underscores.
  • Rule names are distinct and are never the reserved lowercase terminals pass or fail. A result may be any string in the stated alphabet, including a name that is not defined.

More Plaid problems

  • Validate and Resolve Evaluation ChainsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Total Pipeline Completion TimePHONE SCREEN · Seen Sep 2026
  • Bounded Token-Bucket Request QueueONSITE INTERVIEW · Seen Jul 2026
All Plaid interview questionsSee Plaid hiring insights
Saved
class Solution {
    public boolean[] validateRuleChains(String[][] rules) {
        // Write your solution here.
    }

}
Checking account…