Skip to content

Commit 94cfe98

Browse files
authored
Create 3083-existence-of-a-substring-in-a-string-and-its-reverse.js
1 parent 90c5651 commit 94cfe98

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isSubstringPresent = function(s) {
6+
let res = false
7+
const n = s.length
8+
for(let i = 0; i < n - 1; i++) {
9+
const e = s[i] + s[i + 1]
10+
for(let j = n - 1; j > 0; j--) {
11+
if(s[j] === s[i] && s[j - 1] === s[i + 1]) {
12+
res = true
13+
return res
14+
}
15+
}
16+
}
17+
18+
return res
19+
};

0 commit comments

Comments
 (0)