const getLengthOfStr = (str) => {
// 아래 코드를 작성해주세요.
// 제일 긴 중북되지 않는 알파벳의 길이 반환
// Input : 문자열 output : 숫자
// "abc abc abc" => abc(3) , "st trg" => trg(3)
let temp1 = [];
let temp2 = [];
for (let i = 0; i < str.length; i++) {
let temp = str[i];
for (let j = 0; j < temp1.length; j++) {
if (temp === temp1[j]) {
if (temp2.length < temp1.length) {
temp2 = temp1.slice();
}
temp1 = temp1.splice(j + 1, temp1.length);
break;
}
}
temp1.push(temp);
}
return temp1.length > temp2.length ? temp1.length : temp2.length;
};
중복 판별을 위한 특정 규칙을 찾는 데 시간이 오래 걸렸다.. 생각하는 연습을 많이하자..