0216 Code Kata

Agnes Shin·2022년 2월 20일
0
post-custom-banner
const getLengthOfStr = str => {
  let arr = [];
  let maxLength = 0;
  let alphabet = “”;
  for (let j = 0; j < str.length; j++) {
    for (let i = j; i<str.length; i++) {
      alphabet = str.charAt(i);
      if (arr.includes(alphabet)) {
        if(maxLength < arr.length) {
          maxLength = arr.length;
          console.log(maxLength)
        }
        arr = [];
        break;
      } else {
        arr.push(alphabet);
        console.log(arr)
      }
    }
  }
  return maxLength;
}
console.log(getLengthOfStr(“abcadebfg”))
> module.exports = { getLengthOfStr };```
profile
30기 신윤숙 / FE
post-custom-banner

0개의 댓글