소프트웨어에 대한 모든 것

LeetCode 풀기 - 1079. Letter Tile Possibilities 본문

알고리즘/LeetCode

LeetCode 풀기 - 1079. Letter Tile Possibilities

앤테바 2021. 12. 15. 07:19
반응형

1079. Letter Tile Possibilities

https://leetcode.com/problems/letter-tile-possibilities/

 

Letter Tile Possibilities - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

문제)

솔루션1) - Recursive

class Solution:
    def numTilePossibilities(self, tiles):
        res = set()

        def recur(tiles, path):
            if path in res:
                return

            if path:
                res.add(path)

            for i in range(len(tiles)):
                recur(tiles[:i] + tiles[i + 1:], path + tiles[i])

        recur(tiles, '')
        return len(res)

 

반응형
Comments