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 88b3f42 commit 1fc97cbCopy full SHA for 1fc97cb
todo/candidates/771.jewels-and-stones.js
@@ -0,0 +1,18 @@
1
+/*
2
+ * @lc app=leetcode id=771 lang=javascript
3
+ *
4
+ * [460] LFU Cache
5
+ */
6
+/**
7
+ * @param {string} J
8
+ * @param {string} S
9
+ * @return {number}
10
+ * @description 思路:正则把石头里的宝石replace掉,长度相减,就是结果
11
12
+var numJewelsInStones = function(J, S) {
13
+ let newS = S
14
+ for (let i = 0; i < J.length; i++) {
15
+ newS = newS.replace(new RegExp(J[i], 'g'), '')
16
+ }
17
+ return S.length - newS.length
18
+}
0 commit comments