回答編集履歴

3

文言

2021/11/18 14:11

投稿

int32_t
int32_t

スコア20923

test CHANGED
@@ -12,4 +12,4 @@
12
12
 
13
13
  `const s = new Set(['A', 'B']);` としておいて `if (s.has(category))` とすることもできます。
14
14
 
15
- ( O(1) ないらしい…)
15
+ (ECMA-262 によると、`has()` が O(1) かどうか実装依存とのこと)

2

文言

2021/11/18 14:10

投稿

int32_t
int32_t

スコア20923

test CHANGED
@@ -10,4 +10,6 @@
10
10
 
11
11
 
12
12
 
13
- `const s = new Set(['A', 'B']);` としておいて `if (s.has(category))` で O(1) になります。
13
+ `const s = new Set(['A', 'B']);` としておいて `if (s.has(category))` とすることもます。
14
+
15
+ ( O(1) ではないらしい…)

1

文言

2021/11/18 13:36

投稿

int32_t
int32_t

スコア20923

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- 文字なら `if ('AB'.indexOf(category) != -1)` でいかがでしょうか。
9
+ 文字なら `if ('AB'.indexOf(category) != -1)` でいかがでしょうか。
10
10
 
11
11
 
12
12