FastPrepFind Number of Ways to Split Array
Problems/Find Number of Ways to Split Array

Find Number of Ways to Split Array

Google logoGoogle● MediumNEW GRADOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: 2026-06-26 — This problem duplicates Split and Sort Array. Sighting dates were merged into the more complete version, which is the recommended practice page and receives future updates.

You are given an array A of N integers. You can split the array into two non-empty parts, left and right, sort the elements in each part independently and join them back together.

Your task is to find the number of ways of splitting the array into two parts such that, after sorting the two parts and rejoining them into a single array, the resulting array will be sorted in non-decreasing order. For the array shown above, the answer is 2: the first and third splits result in a sorted array.

Function

findNumberOfWaysToSplitArray(A: int[]) → int

Examples

Example 1

A = [1, 3, 2, 4]return = 2

There are two ways to split the array such that the resulting array is sorted:

  • Splitting into left = [1] and right = [3, 2, 4], resulting in [1, 2, 3, 4].
  • Splitting into left = [1, 3, 2] and right = [4], resulting in [1, 2, 3, 4].

Therefore, the number of ways to split the array is 2.

Constraints

  • 2 <= A.length <= 10^5
  • -10^9 <= A[i] <= 10^9

More Google interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Minimum Seats for One-Way Car PoolingSquadStack.ai · OA
  • Choose ContainersIMC Trading · OAIMC Trading interview questions
  • Find Network CallsAmazon · OA
  • Calculating QuantilesIndeed · OAIndeed interview questions
  • Count Lamps Lighting Each PointCapital One · OACapital One interview questions
  • Minimum Cost to Make Array EqualWalmart · OAWalmart interview questions
  • Temporal AnomaliesInMobi · OAInMobi interview questions
  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN

Interview reports that mention this question

  • Google OA: What It Tests (2026)

Google interview experiences

  • Google L5 Security Engineer Domain Knowledge Round: 1 Experience
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int findNumberOfWaysToSplitArray(int[] A) {
      // write your code here
    }

}
Checking account…