자바/프로그래머스(36)
-
[Programmers/JAVA] 숫자의 표현
내 코드 class Solution { public int solution(int n) { int answer = 0; int c=1; int count=0; while(c
2022.11.30 -
[Programmers/JAVA] 이진 변환 반복하기
내 코드 import java.util.ArrayList; import java.util.List; class Solution { public List solution(String s) { List answer= new ArrayList(); int count=0; int zero=0; while(!s.equals("1")) { String[] sp_s=s.split(""); int one=0; for(int i=0; i
2022.11.30 -
[Programmers/JAVA] 올바른 괄호
내 코드 class Solution { boolean solution(String s) { boolean answer = false; int count=0; for(int i=0; i
2022.11.29 -
[Programmers/JAVA] 최솟값 만들기
내 코드 import java.util.Arrays; class Solution { public int solution(int []A, int []B) { int answer = 0; Arrays.sort(A); Arrays.sort(B); for(int i=0; i
2022.11.29 -
[Programmers/JAVA] 최댓값과 최솟값
내 코드 class Solution { public String solution(String s) { String answer = ""; String[] split=s.split(" "); int max=Integer.parseInt(split[0]); int min=Integer.parseInt(split[0]); for(String i : split) { int num=Integer.parseInt(i); if(maxnum) { min=num; } } answer=min+" "+max; return answer; } } 느낀점 어렵지않았다. 다른 분들 코드를 보니까 내 코드와 똑같지만 좀 더 정리된 느낌이라 보기 좋았다. 정리하는 방법을 배워야겠다.
2022.11.29 -
[Programmers/JAVA] JadenCase 문자열 만들기
내 코드 class Solution { public String solution(String s) { String answer = ""; String[] split_s=s.toLowerCase().split(""); if(!split_s[0].equals(" ")) {//첫문자가 공백이 아니라면 대문자로 split_s[0]=split_s[0].toUpperCase(); } for(int i=0; i
2022.11.29