FastPrepProcess Refunds with Bounded Retries
Problems/Process Refunds with Bounded Retries

Process Refunds with Bounded Retries

Mercor logoMercor● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report supplies refund status lookup, an external payment attempt, at most three retries, and a rule that completion is stored only after success. It omits a runner interface; this practice version uses a finite per-request outcome sequence. The judged core task matches the visible report at about 85%.

Process independent refund requests. alreadyDone[i] tells whether request i was completed before this batch. attemptPatterns[i] lists the outcomes returned by successive payment attempts: S is success and F is failure.

If a request is already done, make zero attempts and return DONE:0. Otherwise make at most three attempts and stop on the first success. Return DONE:k after a success on attempt k. If every available attempt among the first three fails, return PENDING:k, where k is the number attempted.

Function

processRefundRetries(alreadyDone: boolean[], attemptPatterns: String[]) → String[]

Examples

Example 1

alreadyDone = [false,false,true]attemptPatterns = ["FFS","FFFF","S"]return = ["DONE:3","PENDING:3","DONE:0"]

A refund becomes done only after success, and an existing completion performs no attempt.

Example 2

alreadyDone = [false,false]attemptPatterns = ["S","FS"]return = ["DONE:1","DONE:2"]

The first success stops retries.

Example 3

alreadyDone = []attemptPatterns = []return = []

An empty batch has no results.

Constraints

  • 0 <= alreadyDone.length == attemptPatterns.length <= 100000.
  • Every pattern has length from 0 through 100 and contains only S and F.
  • Requests are independent.

More Mercor problems

  • Expected Fake-Name CollisionsPHONE SCREEN · Seen Oct 2026
  • Length of a Document Reached Through a Random TokenPHONE SCREEN · Seen Oct 2026
  • Precision of Stacked PII Detector FlagsPHONE SCREEN · Seen Oct 2026
All Mercor interview questionsSee Mercor hiring insights
Saved
class Solution {
    public String[] processRefundRetries(boolean[] alreadyDone, String[] attemptPatterns) {
        // Write your solution here.
    }
}
Checking account…