[프로그래머스/Java] Lv.0 원소들의 곱과 합 문제 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.Arrays; class Solution { public int solution(int[] num_list) { int sum = Arrays.stream(num_list).sum(); int multiply = 1; for (int i : num_list) { multiply *= i; if (multiply > sum*sum) { return 0; } else { continue; } } return 1; } } Colored by Color Scripter cs [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전
[프로그래머스/Java] Lv.0 홀짝에 따라 다른 값 반환하기 문제 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 class Solution { public int solution(int n) { int answer = 0; if (n % 2 == 0) { while (n > 0) { answer += (n*n); n -= 2; } } else { while (n > 0) { answer += n; n -= 2; } } return answer; } } Colored by Color Scripter cs [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전
[프로그래머스/Java] Lv.0 두 수의 연산값 비교하기 문제 풀이 1 2 3 4 5 6 class Solution { public int solution(int a, int b) { return Math.max(Integer.parseInt("" + a + b), 2*a*b); } } Colored by Color Scripter cs [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전
[프로그래머스/Java] Lv.0 문자열 곱하기 문제 풀이 1 2 3 4 5 6 7 8 9 10 class Solution { public String solution(String my_string, int k) { String ans = ""; for (int i = 0; i [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전
[프로그래머스/Java] Lv.0 홀짝 구분하기 문제 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n%2 == 0) { System.out.println(n + " is even"); } else { System.out.println(n + " is odd"); } } } Colored by Color Scripter cs [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전
[프로그래머스/Java] Lv.0 문자열 붙여서 출력하기 문제 풀이 1 2 3 4 5 6 7 8 9 10 11 12 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); System.out.println(a + b); } } Colored by Color Scripter cs [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전
[프로그래머스/Java] Lv.2 귤 고르기 문제 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import java.util.*; import java.util.stream.Collectors; class Solution { public int solution(int k, int[] tangerine) { List arr = Arrays.stream(tangerine).boxed().collect(Collectors.toList()); //list 로 변환 Map freqMap = new HashMap(); //귤의 size 가 key, 중복크기 개수가 value for (int size : arr) { //arr 에서 하나씩 귤을 뽑음 freqMap.put(siz.. [JAVA] 프로그래머스 스쿨/JAVA Lv.2 약 1년 전
[프로그래머스/Java] Lv.0 n의 배수 문제 풀이 1 2 3 4 5 6 class Solution { public int solution(int num, int n) { if (num % n == 0) return 1; return 0; } } Colored by Color Scripter cs [JAVA] 프로그래머스 스쿨/Java Lv.0 약 1년 전