FastPrepSort by Checking Permutations
Problems/Sort by Checking Permutations

Sort by Checking Permutations

Mercor logoMercor● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Mercor phone screen. The report describes listing every permutation and checking if it is sorted. We chose the kind of elements, ascending order, how to handle repeats and empty input, and a small limit on the input size. Our version is about 85% the same as the reported question.

Implement a deliberately inefficient sorting method: generate different orderings (permutations) of values and check whether each is sorted from smallest to largest. Return a sorted permutation.

Every occurrence must be preserved, including duplicate values. The input array may be empty; its sorted permutation is also empty.

The result is the values in ascending order. The exercise is intended to practice permutation generation and sortedness checks, rather than using a library sort.

Discussion follow-up

There is no uniquely slowest sorting algorithm: arbitrary useless work can be added to any correct algorithm to make it slower. Permutation enumeration and sortedness checks remain the concrete deliberately inefficient baseline for this exercise; the required sorted output is unchanged.

Function

permutationSort(values: int[]) → int[]

Examples

Example 1

values = [3,1,2]return = [1,2,3]

The permutation [1,2,3] is nondecreasing and preserves every input value.

Example 2

values = [2,2,-1]return = [-1,2,2]

Both occurrences of 2 remain in the result.

Example 3

values = []return = []

The empty permutation is already sorted.

Constraints

  • 0 <= values.length <= 8.
  • -10^9 <= values[i] <= 10^9.

More Mercor interview questions

  • Expected Fake-Name CollisionsPHONE SCREEN · Seen Oct 2026
  • Length of a Document Reached Through a Random TokenPHONE SCREEN · Seen Oct 2026
  • Precision of Stacked PII Detector FlagsPHONE SCREEN · Seen Oct 2026
  • Coffee Rank ProbabilityPHONE SCREEN · Seen Oct 2026
  • CSV Row SerializerPHONE SCREEN · Seen Sep 2026
  • Process Refunds with Bounded RetriesPHONE SCREEN · Seen Sep 2026
  • Shortest Path in a Grid with Obstacles EliminationPHONE SCREEN · Seen Sep 2026
  • Merge Sort Report with a Noisy ComparatorONSITE INTERVIEW · Seen Sep 2026
  • Top K With a Deterministically Noisy Comparator (MLE)ONSITE INTERVIEW · Seen Sep 2026
  • Minimum Friend API CallsONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • PermutationsEPAM · PHONE SCREENEPAM interview questions
  • Combination Sum with Single-Use ValuesPinterest · PHONE SCREENPinterest interview questions
  • Combination Sum with Unlimited ReuseNVIDIA · PHONE SCREENNVIDIA interview questions
  • Enumerate Valid Clock TimesMicrosoft · OAMicrosoft interview questions
  • Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
  • Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • Subsets IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
  • Partition into Equal-Sum GroupsPalo Alto Networks · ONSITE INTERVIEWPalo Alto Networks interview questions

Mercor interview experiences

  • Mercor New Grad Research Engineer Interviews: 1 Experience
All Mercor interview questionsSee Mercor hiring insights
Saved
class Solution {
    public int[] permutationSort(int[] values) {
        // Write your code here.
    }
}
Checking account…