본문 바로가기

전체 글88

소수 찾기 풀이 class Solution { public int solution(int n) { int answer = 0; for (int i = 2; i
수박수박수박수박수박수? 풀이 class Solution { public String solution(int n) { String answer = ""; if(n%2 == 0){ answer = "수박".repeat(n/2); }else{ answer = "수박".repeat((n-1)/2) + "수"; } return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
문자열을 정수로 바꾸기 풀이 class Solution { public int solution(String s) { int answer = 0; answer = Integer.parseInt(s); return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
시저 암호 풀이 class Solution { public String solution(String s, int n) { StringBuilder answer = new StringBuilder(); for(int i=0; i
약수의 합 풀이 class Solution { public int solution(int n) { int answer = 0; for(int i=1; i
이상한 문자 만들기 풀이 class Solution { public String solution(String s) { StringBuilder answer = new StringBuilder(); String[] words = s.split(" ", -1); for (int i = 0; i < words.length; i++) { words[i] = words[i].toUpperCase(); for (int j = 0; j < words[i].length(); j++) { char currentChar = words[i].charAt(j); if ((j + 1) % 2 == 0 && currentChar != ' ') { // 대문자를 소문자로 변환하는 방법은 currentChar - 'A' + 'a' words[i] = ..