Skip to content

Commit f44964b

Browse files
committed
add 1967
1 parent 7dbba07 commit f44964b

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

javascript/LeetCode/Array/1967.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* 1967. Number of Strings That Appear as Substrings in Word
3+
*
4+
* @param {string[]} patterns
5+
* @param {string} word
6+
* @return {number}
7+
*/
8+
var numOfStrings = function(patterns, word) {
9+
/**
10+
* 計算patterns中有幾個元素出現在word中
11+
*/
12+
let count = 0;
13+
for(let i = 0;i < patterns.length;++i) {
14+
if(word.includes(patterns[i])){
15+
count++;
16+
}
17+
}
18+
return count;
19+
};
20+
let patterns = ["a","abc","bc","d"], word = "abc";
21+
/*
22+
Output: 3
23+
Explanation:
24+
- "a" appears as a substring in "abc".
25+
- "abc" appears as a substring in "abc".
26+
- "bc" appears as a substring in "abc".
27+
- "d" does not appear as a substring in "abc".
28+
3 of the strings in patterns appear as a substring in word.
29+
*/
30+
console.log(numOfStrings(patterns,word));
31+

javascript/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,4 +1409,24 @@ var findErrorNums = function(nums) {
14091409
};
14101410
let nums = [1,2,2,4];
14111411
// [2,3]
1412-
console.log(findErrorNums(nums));
1412+
// console.log(findErrorNums(nums));
1413+
1414+
1415+
/**
1416+
* 2864. Maximum Odd Binary Number
1417+
*
1418+
* @param {string} s
1419+
* @return {string}
1420+
*/
1421+
var maximumOddBinaryNumber = function(s) {
1422+
/**
1423+
* binary string s包含至少一個'1'
1424+
* rearrange 參數s成最大的奇二進制數
1425+
* 回傳的結果值開頭可以是0
1426+
*/
1427+
1428+
};
1429+
let s = "010";
1430+
// Output: "001"
1431+
// Explanation: Because there is just one '1', it must be in the last position. So the answer is "001".
1432+
console.log(maximumOddBinaryNumber(s));

0 commit comments

Comments
 (0)