PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/SoFi

Generate all permutations of an array

Last updated: May 10, 2026

Quick Overview

This question evaluates understanding of permutation generation, recursion and backtracking techniques, along with skills in state-space exploration and analysis of time and space complexity.

  • medium
  • SoFi
  • Coding & Algorithms
  • Software Engineer

Generate all permutations of an array

Company: SoFi

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem Given an array `nums` of **distinct** integers, return **all possible permutations** of the array. A permutation is an ordering of all elements in the array, and each element must appear **exactly once** in each permutation. ## Input - `nums`: an array of integers with no duplicates. ## Output - A list of permutations, where each permutation is a list/array of integers. - You may return the permutations in **any order**. ## Constraints - `1 <= nums.length <= 10` - `-10 <= nums[i] <= 10` - All values in `nums` are unique. ## Example **Input:** `nums = [1,2,3]` **Output (one valid ordering):** ``` [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] ``` ## Notes - Aim for a solution using DFS/backtracking. - Consider how to track which elements have been used in the current partial permutation.

Quick Answer: This question evaluates understanding of permutation generation, recursion and backtracking techniques, along with skills in state-space exploration and analysis of time and space complexity.

Related Interview Questions

  • Find Smallest Common Row Value - SoFi (easy)
  • Format words into wrapped/justified lines - SoFi (medium)
  • Find the second most frequent tag - SoFi (medium)
  • Implement a multithreaded task executor with semaphores - SoFi (medium)
  • Implement chance of a personal best - SoFi (hard)
SoFi logo
SoFi
Jan 16, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
9
0
Coding Console
Loading...

Problem

Given an array nums of distinct integers, return all possible permutations of the array.

A permutation is an ordering of all elements in the array, and each element must appear exactly once in each permutation.

Input

  • nums : an array of integers with no duplicates.

Output

  • A list of permutations, where each permutation is a list/array of integers.
  • You may return the permutations in any order .

Constraints

  • 1 <= nums.length <= 10
  • -10 <= nums[i] <= 10
  • All values in nums are unique.

Example

Input: nums = [1,2,3]

Output (one valid ordering):

[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2],
  [3,2,1]
]

Notes

  • Aim for a solution using DFS/backtracking.
  • Consider how to track which elements have been used in the current partial permutation.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More SoFi•More Software Engineer•SoFi Software Engineer•SoFi Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.