๋ฌธ์ ๐ฝ
https://school.programmers.co.kr/learn/courses/30/lessons/87390
๋ค๋ฅธ์ฌ๋ ํ์ด ๐ฝ
function solution(n, left, right) {
var answer = [];
for (let i = left; i <= right; i++) {
answer.push(Math.max(i % n, parseInt(i / n)) + 1)
}
return answer;
}
๋ดํ์ด๐ฝ
1. ์คํจ โ => ( ์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ๋ค .. )
function solution(elements) {
var answer = 0;
let stack = []
for(let i=1; i<=elements.length; i++){
for(let j=0; j<elements.length; j++){
let sum =0;
for(let z=j; z<j+i; z++){
if(z>=elements.length){
sum+=elements[z-elements.length+1]
}else{
sum+=elements[z]
}
}
stack.push(sum)
}
}
answer = new Set(stack)
answer = [...answer]
return answer.length;
}
2. ์ฑ๊ณต โญ
function solution(n, left, right) {
let answer =[]
const returnArrayValue = (index,t)=>{
let num1=Math.ceil((index+1)/t)
let num2=(index+1)%t
if(num2===0){
num2=t
}
if(num1>=num2){
return num1
}else{
return num2
}
}
for(let i=left; i<=right; i++){
answer.push(returnArrayValue(i,n))
}
return answer
}
๋๋์ ๐ฝ
์ฐ์ฐ์์ ()๋ฅผ ํ์ง ์์ num1 = Math.ceil((index+1)/t) โ ์๋ถ๋ถ์์ ๊ณ์ ์๋ฌ๊ฐ ๋ฌ์๋ค....
๊ทธ๋ฆฌ๊ณ ๋ฌธ์ ๋ฅผ ์ ๋๋ก ์ฝ์ง์์์๋ ์๊ฐ์ด ์ค๋๊ฑธ๋ ธ๋ค...