Skip to content

Instantly share code, notes, and snippets.

View haruple97's full-sized avatar
😁

Kim Dong Hwan haruple97

😁
View GitHub Profile
@haruple97
haruple97 / Solution.java
Created October 28, 2021 06:23
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€/JAVA κ°€μš΄λ° κΈ€μž κ°€μ Έμ˜€κΈ° (substring)
class Solution {
public String solution(String s) {
String answer = "";
if(s.length() % 2 == 0){ //짝수
answer = s.substring(s.length()/2-1, s.length()/2+1);
}else { //ν™€μˆ˜
answer = s.substring(s.length()/2, s.length()/2+1);
}
@haruple97
haruple97 / Solution.java
Last active October 28, 2021 06:03
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€/JAVA 같은 μˆ«μžλŠ” μ‹«μ–΄
import java.util.ArrayList;
public class Solution {
public int[] solution(int []arr) {
int[] answer = {};
ArrayList<Integer> arrList = new ArrayList<Integer>();
int num = -1; //μ›μ†Œκ°€ 0~9κΉŒμ§€ μ΄λ―€λ‘œ 영ν–₯ μ•ˆλ°›λŠ” 아무 숫자.
for(int i=0; i<arr.length; i++){
if(arr[i] != num){
@haruple97
haruple97 / Solution.java
Created October 28, 2021 05:27
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€/JAVA λΆ€μ‘±ν•œ κΈˆμ•‘ κ³„μ‚°ν•˜κΈ°
class Solution {
public long solution(int price, int money, int count) {
long answer;
long sum = 0;
long result;
//μš”κΈˆ ν•© 계산
for(int i=1; i<count+1; i++){
result = i * price;
sum += result;
@haruple97
haruple97 / Solution.java
Created October 28, 2021 05:00
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€/JAVA λ‚˜λ¨Έμ§€κ°€ 1이 λ˜λŠ” 수 μ°ΎκΈ°
class Solution {
public int solution(int n) {
int answer = 0;
for (int i=2; i<n; i++){
if(n%i == 1){
answer = i;
break;
}
}
@haruple97
haruple97 / Solution.java
Created October 28, 2021 04:37
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€/JAVA μ˜ˆμ‚°
import java.util.*;
class Solution {
public int solution(int[] d, int budget) {
int answer = 0;
int result = 0; //μ˜ˆμ‚° κ²°κ³Ό
Arrays.sort(d); //μ •λ ¬
//μž‘μ€ μˆ˜λΆ€ν„° λ”ν•˜λŠ” 것이 κ°€μž₯ μ΅œλŒ€μ˜ 값을 λ‚Έλ‹€.
for(int i=0; i<d.length; i++){
@haruple97
haruple97 / Solution.java
Created October 26, 2021 08:11
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€/JAVA μ™„μ£Όν•˜μ§€ λͺ»ν•œ μ„ μˆ˜
import java.util.*;
class Solution {
public String solution(String[] participant, String[] completion) {
String answer = "";
//participant : λ§ˆλΌν†€μ— μ°Έμ—¬ν•œ μ„ μˆ˜λ“€μ˜ 이름 λ°°μ—΄
//completion : μ™„μ£Όν•œ μ„ μˆ˜λ“€μ˜ 이름이 λ‹΄κΈ΄ λ°°μ—΄
Arrays.sort(participant);
@haruple97
haruple97 / Solution.java
Created October 26, 2021 07:14
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€ JAVA μ΅œμ†Œμ§μ‚¬κ°ν˜•
class Solution {
public int solution(int[][] sizes) {
int max_width = 0;
int max_height = 0;
int wallet_size;
for(int i=0; i<sizes.length; i++){
int temp;
@haruple97
haruple97 / Solution.java
Created October 26, 2021 06:18
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€JAVA μˆ˜λ°•μˆ˜λ°•μˆ˜λ°•μˆ˜λ°•μˆ˜?
class Solution {
public String solution(int n) {
String answer = "";
String su = "수";
String bac = "λ°•";
for(int i=0; i<n; i++){
//짝수
if(i % 2 == 0){
@haruple97
haruple97 / Baekjoon_1157.java
Created October 19, 2021 14:41
Baekjoon_1157.java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[26]; //영문자 갯수 26개
String word = sc.next();
@haruple97
haruple97 / Solution.java
Created October 19, 2021 13:27
ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€ JAVA / 체윑볡
class Solution {
public int solution(int n, int[] lost, int[] reserve) {
int answer = 0; //μ²΄μœ‘μˆ˜μ—… 듀을 수 μžˆλŠ” ν•™μƒμ˜ μ΅œλŒ€κ°’
int count = 0; //빌린 학생 수
//μ—¬λ²Œ μ˜·μ„ κ°€μ§€κ³  μžˆλŠ” 학생이 λ„λ‚œ λ‹Ήν•˜λ©΄ λΉŒλ €μ€„ 수 없도둝 λ§Œλ“ λ‹€.
for(int i=0; i<lost.length; i++){
for(int j=0; j<reserve.length; j++){
if(lost[i]==reserve[j]){ //λ„λ‚œ λ‹Ήν•œ 학생 == μ—¬λ²Œμ˜· κ°€μ Έμ˜¨ 학생
lost[i] = reserve[j] = -1; //-1둜 μ΄ˆκΈ°ν™”