FastPrepPins Violation Log Queries
Problems/Pins Violation Log Queries

Pins Violation Log Queries

Pinterest logoPinterest● MediumFULLTIMENEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Pinterest phone screen. The report keeps the record fields and five kinds of queries. It does not give the handling of repeats, the order of results, how to write them, or the function signature. Our version is about 85% the same as the reported question.

You are given violation records, already sorted by time. Each row is [postId, policy, timestamp], and timestamp is an integer written as a decimal string. If the same row appears more than once, it is one violation and counts only once.

Answer each query with one string. When an answer is a list, sort its items lexicographically (plain string order) and join them with commas.

  • ["POSTS_BY_POLICY", policy]: each post ID that broke this policy, listed once.
  • ["POLICIES_BY_POST", postId]: each policy this post broke, listed once.
  • ["POSTS_AT_TIME", timestamp]: each post ID with a violation at exactly this time, listed once.
  • ["POSTS_IN_RANGE", start, end]: each post ID with a violation from start to end, with both ends included, listed once.
  • ["COUNTS_BY_POLICY", start, end]: for each policy, the number of distinct violations from start to end, with both ends included. Write each one as a policy=count pair, list the pairs in sorted order of policy name, and join them with commas.

Return the answer strings in the same order as the queries. If an answer has nothing in it, return the empty string.

Function

answerViolationQueries(records: String[][], queries: String[][]) → String[]

Examples

Example 1

records = [["p2","spam","10"],["p1","spam","10"],["p1","hate","12"],["p2","spam","15"]]queries = [["POSTS_BY_POLICY","spam"],["POLICIES_BY_POST","p1"],["POSTS_AT_TIME","10"],["POSTS_IN_RANGE","11","15"],["COUNTS_BY_POLICY","10","12"]]return = ["p1,p2","hate,spam","p1,p2","p1,p2","hate=1,spam=2"]

The first four answers list unique sorted identifiers. The final answer counts the three distinct violation rows at times 10 through 12.

Constraints

  • 1 <= records.length, queries.length <= 10^5.
  • Post IDs and policies are nonempty strings containing letters, digits, hyphens, or underscores.
  • Timestamps are decimal integers in [0, 10^18].
  • Records are sorted by nondecreasing timestamp.
  • Every query has one of the five documented forms.

More Pinterest Phone Screen questions

  • Shortest Pin Path Through TopicsPHONE SCREEN · Seen Nov 2026
  • Top K Pins with Insert and QueryPHONE SCREEN · Seen Nov 2026
  • Sparse Matrix Addition and MultiplicationPHONE SCREEN · Seen Nov 2026
  • Minimum Bus Routes to a DestinationPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Delete and Compact a Forest SubtreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Optimal Account BalancingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Aggregate Matching IPv4 Addresses Across ResponsesPHONE SCREEN · Seen Oct 2026
  • Escape Room LeaderboardPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Shortest Way to Form a Target StringPHONE SCREEN · Seen Sep 2026
  • Time-Ordered Elevator DispatchPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
  • Resolve Visible User FeaturesStripe · PHONE SCREENStripe interview questions
  • Credit Card Command ProcessorChime · PHONE SCREEN
  • Popular and Instant-Runoff Election WinnersCoursera · PHONE SCREEN
  • AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions
  • Read a File from Distributed ChunksHudson River Trading · ONSITE INTERVIEWHudson River Trading interview questions
  • HTTP Request RedirectionAmazon · OA
  • P&L Leaderboard OperationsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Macaron Order with Set DiscountsShopify · OAShopify interview questions

Pinterest interview experiences

  • Pinterest Experienced MLE Phone Screen: 1 Experience
All Pinterest interview questionsSee Pinterest hiring insights
Saved
class Solution {
    public String[] answerViolationQueries(String[][] records, String[][] queries) {
        // write your code here
    }
}
Checking account…