Output Contest Matches
愚蠢... 这道题就按照顺序往中间压就行了,主要是这种思路类似于堆排序的下沉,写的很少有点不适应
class Solution(object):
def findContestMatch(self, n):
"""
:type n: int
:rtype: str
"""
nums = map(int, range(1, n + 1))
while len(nums) > 1:
tmp = []
for i in xrange(n / 2):
tmp.append('({},{})'.format(nums[i], nums[n - i - 1]))
nums = tmp[:]
n /= 2
return nums[0]