728x90
반응형
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
String.prototype.substring() - JavaScript | MDN
The substring() method returns the part of the string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.
developer.mozilla.org
function solution(t, p) {
let pLen=p.length;
let tLen=t.length;
let sliceStr=t
let res=[]
for(let i=0; i < tLen-pLen+1; i++) {
res.push(sliceStr.substring(i,pLen+i))
}
res=res.filter((i)=>(Number(i)<=Number(p)))
return res.length
}
728x90
반응형
'알고리즘(Algorithm)' 카테고리의 다른 글
프로그래머스 - 숫자 문자열과 영단어 [JS][2021 카카오 인턴] (0) | 2023.01.05 |
---|---|
프로그래머스 - 모의고사 [JS] (0) | 2022.12.30 |
프로그래머스 - 문자열 나누기[JS] (0) | 2022.12.19 |
프로그래머스 - 가장 가까운 글자 [JS] (0) | 2022.12.18 |
프로그래머스 시저 암호 [JS] (0) | 2022.12.17 |