Reported July 2026
Googlearray

Count Sortable Splits

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google, July 2026. The OA hands you "Count Sortable Splits" and it looks like a sorting problem. It isn't. Sorting each half and joining them is sorted only when every element on the left is less than or equal to every element on the right. That's a prefix max versus suffix min check, nothing more. If you've got an invite in your inbox, this is a 10 minute problem once you see it. If you blank under the clock, StealthCoder runs invisibly on your screen and gives you the solution as a safety net. Don't brute force it.

The problem

You are given an integer array A of length N.
Choose one split position that divides A into two non-empty contiguous parts, called left and right. Sort the elements in each part independently in non-decreasing order, then join the sorted left part followed by the sorted right part.
Return the number of split positions for which the joined array is sorted in non-decreasing order.

Function
solution(A: int[]) → int

Examples
Example 1
A = [1, 3, 2, 4]
return = 2
There are three possible split positions:
left = [1] and right = [3, 2, 4] produce [1, 2, 3, 4], so this split works.
left = [1, 3] and right = [2, 4] produce [1, 3, 2, 4], so this split does not work.
left = [1, 3, 2] and right = [4] produce [1, 2, 3, 4], so this split works.
Therefore, the answer is 2.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Here's the reduction. After sorting both parts, the joined array is sorted exactly when max(left) <= min(right). Each part is already sorted internally, so the only possible violation is at the seam. Build a prefix max array and a suffix min array in two linear passes. Then for each split index i from 1 to N-1, count it if prefixMax[i-1] <= suffixMin[i]. That's O(N) time and O(N) space. The common pitfall is sorting both halves for every split, which is O(N^2 log N) and will time out on large inputs. Another trap is using strict less-than. Duplicates are allowed because the target is non-decreasing, so use <=. Also remember both parts must be non-empty, so splits run from 1 to N-1. If the live OA freezes your brain, StealthCoder is the hedge that keeps you moving.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Count Sortable Splits cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Sortable Splits FAQ

What's the trick to Count Sortable Splits?+

A split works only if the max of the left part is less than or equal to the max-free boundary of the right, meaning the min of the right. Sorting inside each part doesn't change those two values. Precompute prefix max and suffix min, then compare at each split.

How hard is this problem really?+

Easy to medium. The code is short, about 10 lines. The difficulty is realizing you don't need to sort anything. Once you spot the max-left versus min-right condition, it's a linear scan with two helper arrays.

Should I use less-than or less-than-or-equal?+

Use less-than-or-equal. The joined array only needs to be non-decreasing, so equal values across the seam are fine. A strict comparison will undercount on inputs with duplicates, which is the most common wrong answer here.

Can I do it in O(1) extra space?+

Mostly yes with some care, but it's not worth it. Two arrays of size N are fine for this problem. Compute the suffix min array, then sweep left to right keeping a running prefix max. That uses one extra array.

How do I prepare for this in 48 hours?+

Practice prefix and suffix array problems, where you precompute running max or min from each side. Then write this one from scratch twice. Test on already sorted arrays, reverse sorted arrays, all equal values, and length 2 arrays to catch off-by-one errors on split bounds.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it