| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/cppp/LeetCode-Solutions/master/Python/beautiful-array.py | [Back] [Original] |
# Time: O(n)
# Space: O(n)
class Solution(object):
def beautifulArray(self, N):
"""
:type N: int
:rtype: List[int]
"""
result = [1]
while len(result) < N:
result = [i*2 - 1 for i in result] + [i*2 for i in result]
return [i for i in result if i
| Web Proxy Viewer | New URL | Original Page |