FastPrepPolicy Violation Set Checks
Problems/Policy Violation Set Checks

Policy Violation Set Checks

Pinterest logoPinterest● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report supplies a three-part policy-violation exercise, HashSet state, and follow-ups about which of three sets need checking and how to optimize. It omits the sets' domain meanings, request fields, result encoding, and bounds; the minimal three-deny-set adapter supplies those details. The practice contract matches the report at about 72%.

A request is [user, resource, action]. Three independent deny sets contain blocked users, blocked resources, and blocked actions.

For every request, return true exactly when at least one of its three fields appears in the corresponding deny set. Return the decisions in input order.

Function

findPolicyViolations(blockedUsers: String[], blockedResources: String[], blockedActions: String[], requests: String[][]) → boolean[]

Examples

Example 1

blockedUsers = ["u2"]blockedResources = ["secret"]blockedActions = ["delete"]requests = [["u1","public","read"],["u2","public","read"],["u1","secret","read"],["u1","public","delete"]]return = [false,true,true,true]

The last three requests each match one deny set.

Example 2

blockedUsers = []blockedResources = []blockedActions = []requests = [["a","b","c"]]return = [false]

No deny rule applies.

Example 3

blockedUsers = ["x"]blockedResources = ["r"]blockedActions = ["write"]requests = [["x","r","write"],["y","r","write"]]return = [true,true]

A request remains one violation even when several deny sets match.

Constraints

  • 0 <= blockedUsers.length, blockedResources.length, blockedActions.length <= 100000.
  • 1 <= requests.length <= 100000.
  • Every request contains exactly three nonempty strings.
  • Identifiers contain 1 to 40 visible ASCII characters.
  • Each deny-set input contains unique values.

More Pinterest problems

  • Gaussian Naive Bayes Classifier (Machine Learning OA)OA · Seen Nov 2026
  • Top K Pins with Insert and QueryPHONE SCREEN · Seen Nov 2026
  • Pins Violation Log QueriesPHONE SCREEN · Seen Nov 2026
All Pinterest interview questionsSee Pinterest hiring insights
Saved
class Solution {
    public boolean[] findPolicyViolations(String[] blockedUsers, String[] blockedResources, String[] blockedActions, String[][] requests) {
        // Write your solution here.
    }
}
Checking account…