Python, Simple with Explanation

  • 2

    For each round R consisting of a list of match results, pair the new round by matching player i with len(R)-1-i.

    def findContestMatch(self, n):
        R = tuple(range(1, n+1))
        while len(R) > 2:
            R = tuple((R[i],R[~i]) for i in xrange(len(R)/2))
        return str(R).replace(' ','')

Log in to reply

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