[Coding Test]크기가 작은 부분문자열

이묘·2022년 12월 23일
0

CodingTest

목록 보기
34/41
post-thumbnail

function solution(t, p) {

  const result = [];

  for (var i = 0; i < t.length; i++) {
    sliceWord = t.slice(i, i+p.length)
    if(sliceWord.length === p.length){
      result.push(sliceWord)
    }
  }

  answer = result.filter((num) => Number(num) <= Number(p))

  return answer.length;
}

console.log(solution("500220839878",	"7"))
profile
본질을 공부해야 응용도 하지 않을까

0개의 댓글