FastPrepFind Fair Indexes
Problems/Find Fair Indexes

Find Fair Indexes

Microsoft logoMicrosoft● EasyOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given two arrays A and B consisting of N integers each.

Index K is named fair if the four sums A[0]+...A[K-1]), A[K]+...+A[N-1]), B[0]+...+B[K-1]) and B[K]+...+B[N-1]) are all equal. In other words, K is the index where the two arrays, A and B, can be split (into two non-empty arrays each) in such a way that the sums of the resulting arrays' elements are equal.

For example, given arrays A = [4,-1, 0, 3] and B = [-2, 5, 0, 3], index K = 2 is fair. The sums of the subarrays are all equal: 4+(-1) = 3; 0+3 = 3; -2 + 5 = 3 and 0 + 3 = 3.

Function

findFairIndex(A: int[], B: int[]) → int

Examples

Example 1

A = [4,-1,0,3]B = [-2,5,0,3]return = 2

Index K = 2 is fair. The sums of the subarrays are all equal: 4+(-1) = 3; 0+3 = 3; -2 + 5 = 3 and 0 + 3 = 3.

Example 2

A = [2,-2,-3,3]B = [0,0,4,-4]return = 1

Index K = 1 is fair. The sums of the subarrays are all equal: 2 = 2; -2+(-3)+3 = 0; 0 = 0; 0+4+(-4) = 0.

Example 3

A = [4,-1,0,3]B = [-2,6,0,4]return = 0

There is no fair index K in this case.

Example 4

A = [1,4,2,-2,5]B = [7,-2,-2,2,5]return = 2

Index K = 2 is fair. The sums of the subarrays are all equal: 1+4 = 5; 2+(-2)+5 = 5; 7+(-2) = 5; (-2)+2+5 = 5.

Constraints

  • 🥑🥑

More Microsoft interview questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Authentication SystemOA · Seen Nov 2026
  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Maximum String OperationsOA · Seen Nov 2026
  • Minimum Cost to Process Priority TasksOA · Seen Nov 2026
  • Most Visited Sprint MarkerOA · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 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

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int findFairIndex(int[] A, int[] B) {
      // write your code here
    }

}
Checking account…