Short python solution


  • 0
    Z
    class Solution(object):
        def findContestMatch(self, n):
            def helper(m):
                if len(m) == 2:
                    return "(%s,%s)" % tuple(m)
                return helper([helper((m[i], m[~i])) for i in xrange(len(m)/2)])
            return helper(map(str, range(1, n + 1)))

Log in to reply
 

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