Problem · Array
Count Sortable Splits
Problem statement
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.
The problem statement continues
ProExamples
Example 1
A = [1, 3, 2, 4]return = 2There are three possible split positions:
left = [1]andright = [3, 2, 4]produce[1, 2, 3, 4], so this split works.left = [1, 3]andright = [2, 4]produce[1, 3, 2, 4], so this split does not work.left = [1, 3, 2]andright = [4]produce[1, 2, 3, 4], so this split works.
Therefore, the answer is 2.
Original screenshot from the interview report
ProFastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- Worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$9/month
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week