When is it cheating to use libraries?

  • 0

    The first thing I thought when I saw this problem was, "Cross product." So I simply used python's built in itertools to do the cross product, after mapping the digits to the correct letters:

    class Solution:
        # @return a list of strings, [s1, s2]
        def letterCombinations(self, digits):
            possibleLetters = map(lambda s:list(keys.get(s)),digits)
            possibleCombinations = list(itertools.product(*possibleLetters))
            return list(map(''.join,possibleCombinations))

    Is this relying too much on the libraries provided in python?

  • 0

    I would love to avoid powerful libraries.

    It is true that python always make life easier.

  • 0

    I don't agree. Some builtin libraries is the part of the language. Avoid using the libraries is keeping the good part of the language away.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.