본문 바로가기

전체 글

(111)
[프로그래머스] 두 수의 나눗셈.Java 정수 num1과 num2가 매개변수로 주어질 때, num1을 num2로 나눈 값에 1,000을 곱한 후 정수 부분을 return 하도록 soltuion 함수를 완성해주세요 내가 푼 방법 처음 푼 방법 class Solution { public int solution(int num1, int num2) { int answer = (double) num1 /num2 * 1000; return answer; }}-->> 이 방법으로 문제푸니 incompatible types: possible lossy conversion from double to int 오류가 발생 이는소수점 아래의 수가 없어 지기 때문이다. 따라서 int answer = (double) num1 /n..
[프로그래머스] 모스부호(1) / 자비 문제https://school.programmers.co.kr/learn/courses/30/lessons/120838 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이class Solution { public String solution(String letter) { String[] morse = {".-","-...","-.-.","-..",".","..-.", "--.","....","..",".---","-.-",".-..","--","-.", "---",".--.","--.-","..
[프로그래머스] k의 개수 / 자바 문제https://school.programmers.co.kr/learn/courses/30/lessons/120887 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이class Solution { public int solution(int i, int j, int k) { int answer = 0; String kk = String.valueOf(k); for(int a = i; a
[프로그래머스] 7의 개수 / 잡 문제https://school.programmers.co.kr/learn/courses/30/lessons/120912 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이import java.util.*;class Solution { public int solution(int[] array) { int answer = 0; String str = Arrays.toString(array); for(int i=0; i
[프로그래머스] 숨어있는 숫자의 덧셈(2) / 자바 문제https://school.programmers.co.kr/learn/courses/30/lessons/120864 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이class Solution { public int solution(String my_string) { int answer = 0; my_string = my_string.toLowerCase(); // 대문자를 소문자로 변경 // 배열로 만드는데 영문자는 " "로 바꾼다. String[] str = my_string.replac..
[프로그래머스] 중복된 문자 제거 / 자바 문제https://school.programmers.co.kr/learn/courses/30/lessons/120888 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이class Solution { public String solution(String my_string) { String answer = ""; for(int i=0; i
[프로그래머스] 배열회전시키기 /자바 문제https://school.programmers.co.kr/learn/courses/30/lessons/120844 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이class Solution { public int[] solution(int[] numbers, String direction) { int[] answer = new int[numbers.length]; if(direction.equals("right")) { for(int i=0; i
[프로그래머스] 진료순서 정하기 / 자바 문제https://school.programmers.co.kr/learn/courses/30/lessons/120835 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr풀이 class Solution { public int[] solution(int[] emergency) { int[] answer = new int[emergency.length]; for(int i=0; i