Skip to content

Commit c253d3b

Browse files
committed
88
1 parent c63167c commit c253d3b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Day88/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
var countArrangement = function(n) {
6+
7+
8+
let checker = new Array(n).fill(false);
9+
let result = 0;
10+
dfs(1,n)
11+
12+
function dfs(val,n){
13+
if(val > n){
14+
result++;
15+
return;
16+
}
17+
18+
19+
for(let i=1; i <=n; i++){
20+
21+
if(!checker[i] && (i % val == 0 || val % i ==0)){
22+
checker[i] = true;
23+
dfs(val+1, n);
24+
checker[i] = false;
25+
}
26+
}
27+
}
28+
29+
return result;
30+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
194194

195195
|Day 86| [426. Convert Binary Search Tree to Sorted Doubly Linked List](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/submissions/) | [javascript]()|[:memo:](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/submissions/)|Medium|
196196

197-
|Day 87| [1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/)|Medium|
197+
|Day 87| [1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/)|Medium|
198+
199+
|Day 88| [526. Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement/) | [javascript]()|[:memo:](https://leetcode.com/problems/beautiful-arrangement/)|Medium|

0 commit comments

Comments
 (0)