-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path932.beautiful-array.py
More file actions
49 lines (46 loc) · 894 Bytes
/
932.beautiful-array.py
File metadata and controls
49 lines (46 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# @lc app=leetcode id=932 lang=python3
#
# [932] Beautiful Array
#
# https://leetcode.com/problems/beautiful-array/description/
#
# algorithms
# Medium (66.47%)
# Likes: 1095
# Dislikes: 1545
# Total Accepted: 48.6K
# Total Submissions: 72.9K
# Testcase Example: '4'
#
# An array nums of length n is beautiful if:
#
#
# nums is a permutation of the integers in the range [1, n].
# For every 0 <= i < j < n, there is no index k with i < k < j where 2 *
# nums[k] == nums[i] + nums[j].
#
#
# Given the integer n, return any beautiful array nums of length n. There will
# be at least one valid answer for the given n.
#
#
# Example 1:
# Input: n = 4
# Output: [2,1,4,3]
# Example 2:
# Input: n = 5
# Output: [3,1,2,5,4]
#
#
# Constraints:
#
#
# 1 <= n <= 1000
#
#
#
# @lc code=start
class Solution:
def beautifulArray(self, n: int) -> List[int]:
# @lc code=end