Trains the technique from
LeetCode 990Satisfiability of Equality EquationsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A test rig has terminals labelled with single lowercase letters. A technician hands you claims, a list of measurements each written as exactly four characters:
claims[i][0] and claims[i][3] are the two terminal labels;claims[i][1] is '=' when the claim is that the two terminals carry the same voltage, or '!' when the claim is that they carry different voltages;claims[i][2] is always '='.So "c==d" claims terminals c and d sit at one voltage, and "c!=d" claims they do not. A claim may name the same terminal on both sides.
Decide whether some assignment of an integer voltage to every terminal label makes all the claims hold at the same time. Return true if such an assignment exists and false otherwise.
Example 1
The first two claims put `r`, `s` and `t` all at one voltage, which leaves the third claim asking for `t` and `r` to differ while they are forced to agree.
Example 2
Setting `h`, `j` and `m` to 4 and `k` to 9 satisfies every claim: the two sameness claims hold and `k` differs from `j`.
Example 3
The claim asks terminal `w` to carry a voltage different from its own, which no assignment can do.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def claims_consistent(claims: list[str]) -> bool:public boolean claimsConsistent(String[] claims)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.