FastPrepTransaction Authorizer with Velocity Rules
Problems/Transaction Authorizer with Velocity Rules

Transaction Authorizer with Velocity Rules

Goldman Sachs logoGoldman Sachs● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Goldman Sachs technical-screen report asks for a TransactionAuthorizer. It applies per-user merchant-category blacklists, and declines when the attempted spend in a rolling hour is above $5,000. The report does not give the record format or the exact rule at the edge of the hour. This version handles a batch in time order. Our version is about 91% the same as the reported question.

You are given card transaction attempts in time order. Decide for each attempt whether it is approved or declined.

  • Each blockedRules row is [userId, mcc]. The MCC is a merchant category code, which names a kind of shop. The row means that user may not pay in that category.
  • Each transactions row is [userId, mcc, amount, timestamp]. The amount is a positive whole number of dollars. The timestamp is a Unix time in seconds.

An attempt is DECLINED in either of two cases. First, its MCC is blocked for that user. Second, the user is spending too fast. To check this, add up the amounts of all of that user's attempts in the interval (timestamp - 3600, timestamp], counting the current attempt. This interval is the last hour. It leaves out the moment exactly one hour back and includes the current moment. If the total is more than 5000, the attempt is declined. Otherwise it is APPROVED.

A declined attempt still counts toward the one-hour totals of later attempts. Return one result per transaction.

Function

authorizeTransactions(blockedRules: String[][], transactions: String[][]) → String[]

Examples

Example 1

blockedRules = [["u1","7995"]]transactions = [["u1","5411","3000","0"],["u1","7995","100","10"],["u1","5411","2000","20"],["u1","5411","2000","3620"]]return = ["APPROVED","DECLINED","DECLINED","APPROVED"]

The second attempt is declined because its MCC is blocked for this user. The third attempt is declined too: the first three attempts add up to 5100 by time 20, which is over the limit. At time 3620, the one-hour interval is open on the left, so it leaves out all three earlier attempts, even the one exactly an hour back. Only the current amount counts, so the last attempt is approved.

Example 2

blockedRules = []transactions = [["a","1","4000","5"],["b","1","4000","5"],["a","1","1001","6"]]return = ["APPROVED","APPROVED","DECLINED"]

Each user has a separate one-hour total. User a's two attempts add up to more than the limit, so a's second attempt is declined. User b's attempt does not count toward a's total, so b is approved.

Constraints

  • 0 <= blockedRules.length <= 200000
  • 1 <= transactions.length <= 200000
  • User IDs and MCCs are nonempty strings without spaces.
  • 1 <= amount <= 10^9
  • Timestamps are nonnegative and fit in a signed 64-bit integer. Across all transactions, each timestamp is at least as large as the one before it.

More Goldman Sachs Onsite Interview questions

  • Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
  • Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
  • First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
  • Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
  • Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Sliding-Window Rate LimiterAmazon · ONSITE INTERVIEW
  • Rate Limiter with Global and Per-User LimitsOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Per-Element Hit CounterUber · ONSITE INTERVIEWUber interview questions
  • Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Per-Client Sliding-Window Rate LimiterNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Sliding-Window Rate LimiterStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Key-Value Store GET and PUT QPSDatabricks · PHONE SCREENDatabricks interview questions
  • Rate Limiter with a Sliding Window per ClientStackAdapt · PHONE SCREENStackAdapt interview questions
  • Per-Client API Rate LimiterDocker · PHONE SCREEN
  • Per-Client Sliding-Window Rate LimiterCVS Health · PHONE SCREEN
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public String[] authorizeTransactions(String[][] blockedRules, String[][] transactions) {
      // write your code here
    }
}
Checking account…