Tap here to switch tabs
Problem
Submissions

Problem: Beautiful Arrangement

med
30 min
Try to solve the Beautiful Arrangement problem.

Statement

Suppose you have n integers labeled from 11 to n. A 11 indexed permutation of these n integers, perm, is considered a beautiful arrangement if for every index i (1≤1 \leq i ≤\leq n), at least one of the following conditions holds:

  • perm[i] is divisible by i

  • i is divisible by perm[i]

Given an integer n, return the total number of beautiful arrangements that can be constructed.

Constraints:

  • 1≤1 \leq n ≤15\leq 15

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Beautiful Arrangement

med
30 min
Try to solve the Beautiful Arrangement problem.

Statement

Suppose you have n integers labeled from 11 to n. A 11 indexed permutation of these n integers, perm, is considered a beautiful arrangement if for every index i (1≤1 \leq i ≤\leq n), at least one of the following conditions holds:

  • perm[i] is divisible by i

  • i is divisible by perm[i]

Given an integer n, return the total number of beautiful arrangements that can be constructed.

Constraints:

  • 1≤1 \leq n ≤15\leq 15