Skip to content

[심민보]프로그래머스 Lv 0 마무리 #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: minbo
Choose a base branch
from
Open

Conversation

smb0123
Copy link
Owner

@smb0123 smb0123 commented Apr 3, 2024

  • 정사각형으로 만들기
function solution(arr) {
  var answer = [...arr];

  if (answer.length < answer[0].length) {
    for (let i = 0; i < answer[0].length - answer.length; i++) {
      arr.push(Array(answer[0].length).fill(0));
    }
  } else if (answer.length > answer[0].length) {
    for (let j = 0; j < answer.length; j++) {
      for (let i = 0; i < answer.length - answer[j].length; i++) {
        arr[j].push(0);
      }
    }
  }
  return arr;
}

풀이의 틀린점을 모르겠습니다.

  • 외계어 사전
function solution(spell, dic) {
  var answer = 2;
  spell = spell.sort().join("");
  for (let i of dic) {
    if (i.length == spell.length) {
      if (i.split("").sort().join("") == spell) {
        answer = 1;
        break;
      }
    }
  }
  return answer;
}

잘 푼 것 같아서 가져왔습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant