➜ 코딩 테스트/프로그래머스

프로그래머스 - 가까운 1 찾기

class Solution { public int solution(int[] arr, int idx) { for(int i = idx; i

➜ 코딩 테스트/프로그래머스

프로그래머스 - 카운트 다운

class Solution { public int[] solution(int start, int end) { int[] str = new int[start - end +1]; int count = 0; for(int i = start; i >= end; i--){ str[count] = i; count++; } return str; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 글자 지우기

import java.util.*; class Solution { public String solution(String my_string, int[] indices) { StringBuilder str = new StringBuilder(my_string); Arrays.sort(indices); for(int i = indices.length -1; i>= 0; i--){ str.deleteCharAt(indices[i]); } return str.toString(); } } Array.sort까지는했는데 뒤에서부터 지울 생각을못했다.. 바보인가봄..

➜ 코딩 테스트/프로그래머스

프로그래머스 - 배열 만들기1

package Programmers; import java.util.*; public class ProgrammingBasic { public static void main(String[] args) { solution(10, 3); } public static List solution(int n, int k) { List answer = new ArrayList(); for (int i = 1; i

➜ 코딩 테스트/프로그래머스

프로그래머스 - 문자 개수 세기

class Solution { public int[] solution(String my_string) { int[] str = new int[52]; for(int i = 0; i < my_string.length(); i++){ char ch = my_string.charAt(i); if(Character.isUpperCase(ch)){ str[ch - 'A']++; }else{ str[ch - 'a' + 26]++; } } return str; } } 아스키 코드 공부좀 해야겠다

➜ 코딩 테스트/백준

백준 - (1158)요세푸스 문제

이 문제는 Linkedlist를 활용해서 풀었다 이 문제는 K값의 인덱스 값에 맞는 리스트를 삭제하는 문제이다 package S4_Baekjoon; import java.util.LinkedList; import java.util.Scanner; public class Baekjoon1158 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 사용자로부터 N과 K를 입력받음 int N = sc.nextInt(); int K = sc.nextInt(); // 1부터 N까지의 수를 가진 LinkedList 생성 LinkedList list = new LinkedList(); for(int i = 1; i

➜ 코딩 테스트/백준

백준 - (2830)행성 X3

첫 골드 3 문제이다 좀 두려움이 앞섰지만 그래도 풀어보려고 노력해보겠다.. 문제는 어렵지 않다 그냥 XOR 연산 처리한걸 다 합하면 된다 하지만 그냥 풀게 되면 시간 초과가 난다 package G3_Baekjoon; import java.util.Scanner; public class Baekjoon2830 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] X3 = new int[N]; int answer = 0; for (int i = 0; i < N; i++) { X3[i] = sc.nextInt(); } for (int i = 0; i < X3.length..

➜ 코딩 테스트/백준

백준 - (10807)개수 세기

해시 테이블로 풀어야 되는 과제라 해시로 풀었다. package B5_Baekjoon; import java.util.HashMap; import java.util.Scanner; public class Baekjoon10807 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); HashMap hashMap = new HashMap(); for(int i = 0; i < N; i++){ int number = sc.nextInt(); hashMap.put(number, hashMap.getOrDefault(number, 0) +1); } int v = sc.nextInt(); ..

➜ 코딩 테스트/백준

백준 - (9012)괄호

이번 문제는 stack을 활용하는 문제였으나 내가 풀 때는 stack을 쓰지 않고 풀었다. 괄호를 배열로 저장한다음 왼쪽 괄호와 오른쪽 괄호가 나올때 count를 올리거나 내렸다 그래서 만약 오른쪽 괄호가 한번 더 나오는 상황이 나오면 그것도 NO로 출력이 되게 했다. 오른쪽 괄호가 왼쪽 괄호보다 많아지는 상황에 대한 처리를 고민하느라 조금 어려웠다. package S4_Baekjoon; import java.util.Scanner; public class Baekjoon9012 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int T = sc.nextInt(); String[] VPS = new String[..

➜ 코딩 테스트/프로그래머스

프로그래머스 - 숫자 문자열과 영단어

String 값에 문자와 숫자가 섞여있는데 구별하는 문제이다 나는 숫자값은 answer에 따로 추가를 시켜주고 문자값들은 other 에 계속 넣어주고 문자를 완성시키면 other 값을 초기화시키고 숫자로 넣어주는 코드를 작성했다. package Programmers; public class ProgrammingBasic { public static void main(String[] args) { solution("one4seveneight"); } public static int solution(String s) { String answer = ""; String other = ""; for(int i = 0; i < s.length(); i++){ if(Character.isDigit(s.charAt(..

강맹석
'➜ 코딩 테스트' 카테고리의 글 목록 (28 Page)