FastPrepFirst Prefix Reaching a Target Score
Problems/First Prefix Reaching a Target Score

First Prefix Reaching a Target Score

Visa logoVisa● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A December 16, 2025 Visa Senior Software Engineer CodeSignal OA report gives the rule of finding the first prefix, in order, whose sum reaches a threshold, and the -1 result. It leaves out limits, how negative scores work, number size, and a function signature. Our version spells those out.

You are given an integer array scores and an integer target.

Starting from index 0, add the scores in order. Return the first index i for which scores[0] + scores[1] + ... + scores[i] is greater than or equal to target.

If no prefix reaches the target, return -1.

Function

firstPrefixAtLeastTarget(scores: int[], target: int) → int

Examples

Example 1

scores = [2,3,1,4]target = 6return = 2

The prefix sums are 2, 5, and 6. Index 2 is the first index that reaches the target.

Example 2

scores = [-2,5,-1]target = 4return = -1

The prefix sums are -2, 3, and 2, so none reaches 4.

Constraints

  • 1 <= scores.length <= 105
  • -109 <= scores[i], target <= 109
  • Every prefix sum fits in a signed 64-bit integer.

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 2026

Similar questions at other companies

  • Minimum Positive Starting ValueBooking.com · OA
  • Array Interval SumsHeadlands Technologies · OAHeadlands Technologies interview questions
  • Minimum AmountBelvedere Trading · OA
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Range Sum QueriesIntuit · OAIntuit interview questions
  • Shortest Distance on a Circular Bus RouteAmazon · OA
  • Count Sortable SplitsGoogle · OAGoogle interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Range Negation UpdatesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Threshold AlertsGoldman Sachs · OAGoldman Sachs interview questions
All Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public int firstPrefixAtLeastTarget(int[] scores, int target) {
        // Write your code here.
    }

}
Checking account…