본문 바로가기

코테29

코딩테스트 입문 - Day 20 직사각형 넓이 구하기class Solution { public int solution(int[][] dots) { int answer = 0; int o[] = dots[0]; for(int i = 1; i캐릭터의 좌표class Solution { public int[] solution(String[] keyinput, int[] board) { int[] answer = new int[2]; int boundw = board[0] /2; int boundh = board[1] /2; for(String move : keyinput){ switch(move){ .. 2025. 5. 5.
코딩테스트 입문 - Day 19 7의 개수class Solution { public int solution(int[] array) { int cnt = 0; for(int n : array){ String s = n+""; cnt += s.length() - s.replace("7","").length(); } return cnt; }}잘라서 배열로 저장하기import java.util.*;class Solution { public List solution(String my_str, int n) { ArrayList answer = new ArrayList(); int i = 0; while(tr.. 2025. 5. 5.
코딩테스트 입문 - Day 18 문자열안에 문자열class Solution { public int solution(String str1, String str2) { if(str1.contains(str2)){ return 1; } return 2; }}제곱수 판별하기import java.util.*;class Solution { public int solution(int n) { int sq = (int)Math.sqrt(n); int pow = (int) Math.pow((double)sq,2.0); if(n == pow){ return 1; } return 2; }}세균 증.. 2025. 4. 27.
코딩테스트 입문 - Day 17 숫자 찾기class Solution { public int solution(int num, int k) { String s = String.valueOf(num); String k1 = String.valueOf(k); int n = s.indexOf(k1); if(n == -1){ return -1; } return n+1; }}n의 배수 고르기import java.util.*;class Solution { public List solution(int n, int[] numlist) { List arr = new ArrayList(); for(int num : numlis.. 2025. 4. 27.
코딩테스트 입문 - Day 16 편지class Solution { public int solution(String message) { return message.length() * 2; }}가장 큰 수 찾기class Solution { public int[] solution(int[] array) { int max = array[0]; int idx = 0; for(int i =1; i max){ max = array[i]; idx = i; } } return new int[] {max, idx}; }}문자열 계산하기class Solution { public in.. 2025. 4. 27.
코딩테스트 입문 - Day 15 영어가 싫어요class Solution { public long solution(String numbers) { return Long.parseLong(numbers.replace("zero","0") .replace("one","1") .replace("two","2") .replace("three","3") .replace("four","4") .replace("five","5") .replace("six","6") .replace("seven","7") .replace("eight","8") .replace.. 2025. 4. 27.
728x90
반응형