Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Mohammed Dh Abbas
My simpler solution

Mohammed Dh Abbas

Sep 24, 2024

from collections import deque class Solution: def findPermutations(self, nums): def backtrack(index, result, path, seen): if len(path) == len(nums): result.append(path[:]) return for i, num in enumerate(nums): if i not in seen: seen.add(i) path.append(num) backtrack(i, result, path, seen) seen.remove(i) path.pop() result = [] backtrack(0, result, [], set()) return result

0

0

Comments
Comments

On this page