diff --git a/goawmfhfl/1_8.js b/goawmfhfl/1_8.js deleted file mode 100644 index 4ff0580..0000000 --- a/goawmfhfl/1_8.js +++ /dev/null @@ -1,23 +0,0 @@ -function solution(arr){ - let answer = []; - let sum = 0; - - for(let x of arr){ - sum+=x - } - - for(let i=0; i=0; i--){ + if(s[i] === t){ + cnt = 0 + answer[i] = cnt + } + else{ + cnt++ + answer[i]= Math.min(answer[i],cnt) + } + } + + return answer; +} + +let str = "teachermode" +console.log(solution(str,'e')); \ No newline at end of file diff --git a/goawmfhfl/3_5.js b/goawmfhfl/3_5.js new file mode 100644 index 0000000..02d89a8 --- /dev/null +++ b/goawmfhfl/3_5.js @@ -0,0 +1,19 @@ +// 🌟 문제 풀이 🌟 + +function solution(s){ + let answer = []; + let cnt = 1; + + for(let i=0; i1) answer.push(String(cnt)) + cnt = 1 + } + } + return answer.join(''); +} + +let str = "KKHSSSSSSSE" +console.log(solution(str)); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl.1_14.js b/goawmfhfl/goawmfhfl.1_14.js deleted file mode 100644 index 2b9f841..0000000 --- a/goawmfhfl/goawmfhfl.1_14.js +++ /dev/null @@ -1,14 +0,0 @@ -function solution(a){ - let answer= ""; - let min = Number.MIN_SAFE_INTEGER; - for(let x of a){ - let length = x.length; - if(length > min){ - min = length - answer = x - } - } - return answer; -} -let arr =["teacher","time","student","beautiful","good"] -console.log(solution(arr)); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl_1_10.js b/goawmfhfl/goawmfhfl_1_10.js deleted file mode 100644 index c86cbc1..0000000 --- a/goawmfhfl/goawmfhfl_1_10.js +++ /dev/null @@ -1,11 +0,0 @@ -function solution(arr,s){ - let answer = 0; - - for(let x of arr){ - if(x === s) answer++ - } - return answer; -} -let arr = "COMPUTERPROGRAMMING" - -console.log(solution(arr,"R")); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl_1_12.js b/goawmfhfl/goawmfhfl_1_12.js deleted file mode 100644 index 2171054..0000000 --- a/goawmfhfl/goawmfhfl_1_12.js +++ /dev/null @@ -1,25 +0,0 @@ -// 첫 번째 문제 풀이 -function solution(a){ - let answer= ""; - - for(let x of a){ - if(x === x.toLowerCase()) answer+=x.toUpperCase() - else answer+=x - } - return answer; -} -let arr = "itisTimeToStudy" -console.log(solution(arr)); - -// 두 번째 문제 풀이 -function solution2(s){ - let answer = ""; - for(let x of s){ - let num = x.charCodeAt() - if(num >=97 && num <= 122) answer += String.fromCharCode(num-32); - else answer +=x; - } - return answer; -} -let arr2 = "itisTimeToStudy" -console.log(solution2(arr)); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl_1_13.js b/goawmfhfl/goawmfhfl_1_13.js deleted file mode 100644 index 70777e2..0000000 --- a/goawmfhfl/goawmfhfl_1_13.js +++ /dev/null @@ -1,25 +0,0 @@ - -// 첫 번째 문제 풀이 -function solution(a){ - let answer= ""; - for(let x of a){ - let num = x.charCodeAt() - if(num>=97 && num<=122) answer+=String.fromCharCode(num-32) - else answer+=String.fromCharCode(num+32) - } - return answer; -} -let arr = "StuDY" -console.log(solution(arr)); - -// 두 번째 문제 풀이 -function solution(a){ - let answer= ""; - for(let x of a){ - if(x === x.toUpperCase()) answer+=x.toLowerCase() - else answer+=x.toUpperCase() - } - return answer; -} -let arr = "StuDY" -console.log(solution(arr)); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl_1_15.js b/goawmfhfl/goawmfhfl_1_15.js deleted file mode 100644 index 6779c2c..0000000 --- a/goawmfhfl/goawmfhfl_1_15.js +++ /dev/null @@ -1,11 +0,0 @@ -function solution(s){ - let answer=""; - let mid = Math.floor(s.length/2) - - if(s.length%2 === 1) answer=s.substring(mid,mid+1) - else answer = s.substring(mid-1,mid+1) - - return answer; -} -let str = "study" -console.log(solution(str)); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl_1_16.js b/goawmfhfl/goawmfhfl_1_16.js deleted file mode 100644 index 2c9b110..0000000 --- a/goawmfhfl/goawmfhfl_1_16.js +++ /dev/null @@ -1,11 +0,0 @@ -function solution(s){ - let answer=""; - - for(let i=0; i{ - return s.indexOf(v)===i - }) - return answer; -} - -let str = ["good","time","good","time","student"]; -console.log(solution(str)); \ No newline at end of file diff --git a/goawmfhfl/goawmfhfl_1_9.js b/goawmfhfl/goawmfhfl_1_9.js deleted file mode 100644 index ddaa903..0000000 --- a/goawmfhfl/goawmfhfl_1_9.js +++ /dev/null @@ -1,13 +0,0 @@ -function solution(s){ - let answer = ""; - - for(let x of s){ - if(x==="A") answer+="#" - else answer+= x; - } - - return answer; -} - -let str = "BANANA"; -console.log(solution(str)); \ No newline at end of file