Given an array and a range [lowVal, highVal], partition the array into three parts:
lowVal come first.lowVal, highVal] come next.highVal come last.
Additionally:
If lowVal and highVal exist in the array, ensure that lowVal appears before highVal in the final result.
The relative order of elements within each group doesn't matter.
Complete the function threePartitionArray in the editor.
threePartitionArray has the following parameters:
int arr[]: an array of integersint lowVal: an integer representing the lower bound of the rangeint highVal: an integer representing the upper bound of the range
halo frenz - you might want to checkout lc75. They said that these 2 questions are relevant :)
Examples
01 · Example 1
arr = [1, 14, 5, 20, 4, 2, 54, 20, 87, 98, 3, 1, 32] lowVal = 14 highVal = 20 return = [1, 5, 4, 2, 1, 3, 14, 20, 20, 98, 87, 32, 54]
nothin found 🥹
Constraints
nothin found againnnn 😭More Microsoft problems
- Rank Open BusinessesPHONE SCREEN · Seen May 2026
- Retain Top K ValuesPHONE SCREEN · Seen May 2026
- In-Memory SQL with CSV InitializationONSITE INTERVIEW · Seen May 2026
- Order Records by Matching Start and EndONSITE INTERVIEW · Seen May 2026
- Recover Corrupted Master PageONSITE INTERVIEW · Seen Feb 2026
- Get Minimum TimeSeen Jun 2025
- Count Subarrays with Bitwise OR PresentSeen Jun 2025
- Get Max Or SumSeen Jun 2025
public int[] threePartitionArray(int[] arr, int lowVal, int highVal) {
// write your code here
}
arr[1, 14, 5, 20, 4, 2, 54, 20, 87, 98, 3, 1, 32]
lowVal14
highVal20
expected[1, 5, 4, 2, 1, 3, 14, 20, 20, 98, 87, 32, 54]
sign in to submit