Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Shenlin
/
leetcode-test
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2019-06-18 15:12:33 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f77bcc02cea982a4ed766a7d695dab31815ec265
f77bcc02
1 parent
5332e96c
add # 1078
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletions
1078-findOcurrences.js
readme.md
1078-findOcurrences.js
0 → 100644
View file @
f77bcc0
/**
* @param {string} text
* @param {string} first
* @param {string} second
* @return {string[]}
*/
var
findOcurrences2
=
function
(
text
,
first
,
second
)
{
let
target
=
`
${
first
}
${
second
}
`
;
let
rs
=
[];
while
(
text
)
{
let
i
=
text
.
indexOf
(
target
);
if
(
i
>=
0
)
{
console
.
info
(
text
,
i
);
text
=
text
.
substr
(
i
+
target
.
length
);
console
.
info
(
'==>'
,
text
);
let
m
=
/^
(\w
+
)\b
.*/
.
exec
(
text
);
if
(
m
)
{
rs
.
push
(
m
[
1
]);
}
}
else
{
break
;
}
}
return
rs
;
};
var
findOcurrences
=
function
(
text
,
first
,
second
)
{
let
words
=
text
.
split
(
' '
);
let
rs
=
[];
for
(
let
i
=
0
;
i
<
words
.
length
-
2
;
i
++
)
{
if
(
words
[
i
]
===
first
&&
words
[
i
+
1
]
===
second
&&
words
[
i
+
2
])
{
rs
.
push
(
words
[
i
+
2
]);
i
++
;
}
}
return
rs
;
};
console
.
info
(
findOcurrences
(
"we will we will rock you"
,
"we"
,
"will"
));
console
.
info
(
findOcurrences
(
"alice is a good girl she is a good student"
,
"a"
,
"good"
));
\ No newline at end of file
readme.md
View file @
f77bcc0
...
...
@@ -1073,7 +1073,7 @@ leetcode-cn.com上的题库代码实现
| | 1072 |
[
按列翻转得到最大值等行数
](
https://leetcode-cn.com/problems/flip-columns-for-maximum-number-of-equal-rows
)
|
**中等**
|
| | 1073 |
[
负二进制数相加
](
https://leetcode-cn.com/problems/adding-two-negabinary-numbers
)
|
**中等**
|
| | 1074 |
[
元素和为目标值的子矩阵数量
](
https://leetcode-cn.com/problems/number-of-submatrices-that-sum-to-target
)
|
**困难**
|
|
| 1078 |
[
Bigram 分词
](
https://leetcode-cn.com/problems/occurrences-after-bigram
)
|
**简单**
|
|
1078-findOcurrences.js
| 1078 |
[
Bigram 分词
](
https://leetcode-cn.com/problems/occurrences-after-bigram
)
|
**简单**
|
| | 1079 |
[
活字印刷
](
https://leetcode-cn.com/problems/letter-tile-possibilities
)
|
**中等**
|
| | 1080 |
[
根到叶路径上的不足节点
](
https://leetcode-cn.com/problems/insufficient-nodes-in-root-to-leaf-paths
)
|
**中等**
|
| | 1081 |
[
不同字符的最小子序列
](
https://leetcode-cn.com/problems/smallest-subsequence-of-distinct-characters
)
|
**中等**
|
\ No newline at end of file
...
...
Please
register
or
login
to post a comment