Skip to content

Instantly share code, notes, and snippets.

View qkreltms's full-sized avatar
๐Ÿ’–
Happy coding

JungHoonPark qkreltms

๐Ÿ’–
Happy coding
View GitHub Profile
package algorithm;
import java.util.*;
public class Kakao1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine(); //flush
@qkreltms
qkreltms / kakao_1_2.java
Last active March 9, 2018 04:04
์นด์นด์˜คํ†ก ์‹ ์ž… ๊ณต์ฑ„ 1, 2๋ฒˆ ๋ฌธ์ œ
package algorithm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author jack
@qkreltms
qkreltms / kakao_1_2.py
Last active March 8, 2018 12:35
์นด์นด์˜คํ†ก ์‹ ์ž… ๊ณต์ฑ„ 1, 2๋ฒˆ ๋ฌธ์ œ python
import re
def kakao1_2(user):
p = re.compile('[0-9]+')
p2 = re.compile(r"[A-Z]+#*\**")
f = p.findall(user)
f2 = p2.findall(user)
result = [0] * 3
for i in range(3):
def baekjoon11399(length, times_to_wait_in_line):
times_to_wait_in_line.sort()
cal = sum(times_to_wait_in_line)
result = cal
for i in range(length - 1, 0, -1):
cal -= times_to_wait_in_line[i]
result += cal
return result
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static int solve(int length, int[] times_to_wait_in_line) {
Arrays.sort(times_to_wait_in_line);
int cal = Arrays.stream(times_to_wait_in_line)
.reduce((a, b) -> a + b)
.getAsInt();
@qkreltms
qkreltms / baekjoon15501.py
Last active March 9, 2018 03:55
๋ฐฑ์ค€ ์†Œํ”„ํŠธ์ฝ˜ 1ํšŒ A๋ฒˆ ๋ฌธ์ œ https://www.acmicpc.net/problem/15501
def f(n, a, b):
d = [0] * n
dd = [0] * n
a_start_position = a.index(1)
for i in range(n):
j = a_start_position + i #
d[i] = a[j % n] - a[(j + 1) % n] # ํ˜„์žฌ ๊ฐ’๊ณผ ๋‹ค์Œ ๊ฐ’์˜ ์ฐจ๋ฅผ ๊ตฌํ•ด์ฃผ๋Š” ์ ํ™”์‹
b_start_position = b.index(1)
@qkreltms
qkreltms / baekjoon1931.java
Last active March 5, 2018 03:36
baekjoon 1931 : ํšŒ์˜์‹ค ๋ฐฐ์ • https://www.acmicpc.net/problem/1931
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
class Meeting {
public int start;
public int end;
public Meeting(int start, int end) {
this.start = start;
@qkreltms
qkreltms / baekjoon1931.py
Created March 5, 2018 10:08
๋ฐฑ์ค€1931 ํšŒ์˜์‹ค๋ฐฐ์ • https://www.acmicpc.net/problem/1931 python
# ์•ž, ๋’ค ๋‘๋ฒˆ ์ •๋ ฌ ํ•˜๋Š” ์ด์œ ๋Š” [1, 1], [2, 2], [1, 2], [2, 2]๊ฐ™์€ ๋ฐ˜๋ก€๊ฐ€ ์žˆ์Œ
class Meeting:
def __init__(self, begin, end):
self.begin = begin
self.end = end
def algorithm1931():
meeting_list = []
for x in range(int(input())):
@qkreltms
qkreltms / DP_fibonacci.py
Last active March 8, 2018 12:29
ํ”ผ๋ณด๋‚˜์น˜ DP
def fibo_bottom_up(n):
d = [0] * (n+1)
d[0] = 0
d[1] = 1
for i in range(2, n+1):
d[i] = d[i-1] + d[i-2]
return d[n]
def fibo(n):
@qkreltms
qkreltms / approach.txt
Last active March 8, 2018 12:25
https://www.acmicpc.net/problem/1463 : 1๋กœ ๋งŒ๋“ค๊ธฐ <DP, top-down, bottom-up>
๋ฌธ์ œ์˜ ์กฐ๊ฑด์ธ n์ด 1์ด ๋  ์ˆ˜ ์žˆ๋Š”, ์ตœ์†Ÿ๊ฐ’์„ ๊ตฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์€
1. n/3
2. n/2
3. n-1
์ด ์žˆ๋‹ค.
n์—์„œ n/2, n/3, n-1์„ ๊ฑฐ์น˜๋ฉด ํšŸ์ˆ˜๊ฐ€ +1
ํ•œ๋ฒˆ ๊ฑฐ์นœ ํ›„ ์กฐ๊ฑด์„ n ๋ฒˆ์„ ๋ฐ˜๋ณตํ•˜๋ฏ€๋กœ
1 + f(n/2) ,1 + f(n/3),1 + f(n-1)
๋ชจ๋“  ์กฐ๊ฑด์„ ๊ฑฐ์น˜๋ฉด์„œ ์ตœ์†Ÿ๊ฐ’์„ ๊ตฌํ•œ๋‹ค.
์˜ˆ n = 10์ผ ๋•Œ n-1์„ 9๋ฒˆ ๊ฑฐ์ณ๊ฐ„ ๊ฐ’๊ณผ 8๋ฒˆ ๊ฑฐ์ณ๊ฐ„ ํ›„ n/2๋ฅผ ํ•œ ๋ฒˆ ๊ฑฐ์ณ๊ฐ„ ๊ฐ’๊ณผ ๋น„๊ต ํ›„ ๊ฐ’์ด ์ž‘์€ ๊ฒƒ์„ ์‚ฌ์šฉํ•œ๋‹ค.(์ด ๊ฒฝ์šฐ ์„œ๋กœ ๊ฐ™์œผ๋ฏ€๋กœ ํ›„์ž ๊ฐ’์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ)