FastPrepCross-Day User Trust Scores
Problems/Cross-Day User Trust Scores

Cross-Day User Trust Scores

Affirm logoAffirm● EasyFULLTIMEPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report identifies a two-part cross-day trust-score exercise whose score reuses two-day log classifications. A 50/50 two-signal formula and query-aligned output are specified for practice; the judged task matches at about 78%.

A lending service records loan-related activity for two consecutive days. Parallel arrays users, days, and loanTypes describe each log entry.

A user earns 50 trust-score points when they appear on both days, and another 50 points when they have at least two distinct loan types across the complete log. Duplicate entries do not increase either signal.

For each name in queryUsers, return its trust-score percentage in the same order. A user absent from the log has score 0.

Function

calculateTrustScores(users: String[], days: int[], loanTypes: String[], queryUsers: String[]) → int[]

Examples

Example 1

users = ["ana","ana","bob","bob","cara"]days = [1,2,1,1,2]loanTypes = ["personal","auto","card","home","personal"]queryUsers = ["ana","bob","cara","dave"]return = [100,50,0,0]

Ana appears on both days and has two loan types. Bob has two loan types but appears only on day 1. Cara satisfies neither signal, and Dave has no entries.

Example 2

users = ["x","x","x","y","y"]days = [1,1,2,1,2]loanTypes = ["card","card","card","auto","auto"]queryUsers = ["x","y"]return = [50,50]

Both users appear on both days, but repeated entries for one loan type still count as only one distinct type.

Constraints

  • 1 <= users.length == days.length == loanTypes.length <= 200000.
  • 1 <= queryUsers.length <= 200000.
  • days[i] is either 1 or 2.
  • User and loan-type strings contain 1 to 40 lowercase English letters.
  • The total number of characters across all strings is at most 2,000,000.

More Affirm problems

  • Group Transactions by HourONSITE INTERVIEW · Seen Nov 2026
  • Propagating Fraud DetectorPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Count Distinct Underwriting PII ValuesPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
All Affirm interview questionsSee Affirm hiring insights
Saved
class Solution {
    public int[] calculateTrustScores(String[] users, int[] days, String[] loanTypes, String[] queryUsers) {
        // Write your code here.
    }
}
Checking account…