
g0001_0100.s0046_permutations.Solution.ex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
# #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Backtracking
# #Algorithm_I_Day_11_Recursion_Backtracking #Level_2_Day_20_Brute_Force/Backtracking
# #Udemy_Backtracking/Recursion #Big_O_Time_O(n*n!)_Space_O(n+n!)
# #2024_08_02_Time_225_ms_(100.00%)_Space_71.8_MB_(100.00%)
defmodule Solution do
@spec permute(nums :: [integer]) :: [[integer]]
def permute([]), do: [[]]
def permute(nums), do: for h <- nums, t <- permute(nums -- [h]), do: [h | t]
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy