We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e865b8 commit d121bbaCopy full SHA for d121bba
3295-report-spam-message.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * @param {string[]} message
3
+ * @param {string[]} bannedWords
4
+ * @return {boolean}
5
+ */
6
+var reportSpam = function(message, bannedWords) {
7
+ let res = false
8
+ const m = message.length, n = bannedWords.length
9
+ let cnt = 0
10
+ const bs = new Set(bannedWords)
11
+ for(let i = 0; i < m; i++) {
12
+ const str = message[i]
13
+ /*
14
+ for(let j = 0; j < n; j++) {
15
+ const e = bannedWords[j]
16
+ if(str === e) {
17
+ cnt++
18
+ break
19
+ }
20
21
22
+ if(bs.has(str)) cnt++
23
+ if(cnt >= 2) return true
24
25
+
26
+ return res
27
+};
0 commit comments