์ „์ฒด ๊ธ€

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ค€๋น„ ๋ธ”๋กœ๊ทธ: https://velog.io/@chaerlo127
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); try { int N = Integer.parseInt(bf.readLine()); Queue queue = new LinkedList(); Stri..
์กฐํ•ฉ ๊ณต์‹ nCr์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€๋ฉด๋œ๋‹ค. ์ด ๋•Œ, ์žฌ๊ท€ ํ•จ์ˆ˜๋ฅผ ๋ณต์Šตํ•˜๊ธฐ ์œ„ํ•ด factorial ์„ Iteration์ด ์•„๋‹Œ ์žฌ๊ท€๋กœ ๋งŒ๋“ค์—ˆ๋‹ค. ํŒŒ์Šค์นผ ์‚ผ๊ฐํ˜•์— ๋Œ€ํ•ด ์•„์ง ์ž์„ธํžˆ ์•Œ์ง€๋Š” ๋ชปํ•˜์ง€๋งŒ, ์—ด์‹ฌํžˆ ๊ณต๋ถ€ํ•ด๋ด์•ผ๊ฒ ๋‹ค. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); try { String..
ํ•™๊ต 1์ฃผ์ฐจ ์ˆ˜์—…์‹œ๊ฐ„์—์„œ ๋ฐฐ์› ๋˜ recursion์— ๊ด€ํ•œ ๊ธฐ๋ณธ์ ์ธ ๋ฌธ์ œ์ด๋‹ค. while๋ฌธ์„ ์‚ฌ์šฉํ•ด์„œ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์žฌ๊ท€๋ฅผ ๋ณต์Šตํ•˜๊ธฐ ์œ„ํ•ด์„œ recursion์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋ณธ๋‹ค. ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜ : ๋‘ ์ž์—ฐ์ˆ˜์˜ ์ตœ๋Œ€์˜ ์•ฝ์ˆ˜, ๋‚˜๋ˆˆ ์ˆ˜ ์ค‘์—์„œ ๋‘ ์ˆ˜๊ฐ€ ๊ณตํ†ต์œผ๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ตœ๋Œ€์˜ ๊ณตํ†ต ์ž์—ฐ์ˆ˜๋ฅผ ์ผ์ปซ๋Š”๋‹ค. ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ : ๋‘ ์ž์—ฐ์ˆ˜์˜ ์ตœ์†Œ์˜ ๋ฐฐ์ˆ˜, ๋‘ ์ˆ˜์˜ ๋ฐฐ์ˆ˜ ์ค‘์—์„œ ๊ณตํ†ต์ ์ด๋ฉด์„œ ์ตœ์†Œ์˜ ์ž์—ฐ์ˆ˜๋ฅผ ์ผ์ปซ๋Š”๋‹ค. ์ตœ์†Œ ๊ณต๋ฐฐ์ˆ˜๋Š” ๋‘ ์ˆ˜๋ฅผ ๊ณฑํ•œ ๊ฒƒ ์ค‘์—์„œ ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜๋ฅผ ๋‚˜๋ˆ„๋ฉด ๊ฐ’์ด ๋‚˜์˜จ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ์ด ๋ฌธ์ œ์—์„œ ์ค‘์š”ํ•œ ๊ฒƒ์€ ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜๋Š” ๋‘ ์ˆ˜๋ฅผ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€์™€ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๊ฐ’์ด 0์ด ๋˜๊ธฐ ์ด์ „๊นŒ์ง€ ๊ณ„์‚ฐํ•˜์—ฌ ๊ทธ ๋•Œ์˜ ๋ชซ์„ ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜๋กœ..
๊ฐ„๋‹จํ•˜๊ฒŒ ์„œ๋ฒ„ ๋ฐฐํฌ ๋ฐ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌํ•œ ๊ฒƒ์„ ์ •๋ฆฌํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. sudo su # update sudo apt update # nginx proxy server ์‚ฌ์šฉํ•  ์˜ˆ์ •์ด๊ธฐ ๋•Œ๋ฌธ์— nginx ๋‹ค์šด sudo apt install nginx # domain ์—ฐ๊ฒฐ ๋ฐ proxy server ์—ฐ๊ฒฐ # default ํŒŒ์ผ ๋ณ€๊ฒฝ vim /etc/nginx/sites-avaliable/default # default file ๋‚ด๋ถ€ server_name _; # ์ด๋ถ€๋ถ„์— ์›ํ•˜๋Š” ๋„๋ฉ”์ธ ์—ฐ๊ฒฐ location ~~{ # 404 ๋ญ์‹œ๊ธฐ ์ฃผ์„ ์ฒ˜๋ฆฌ proxy_pass http://localhost:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwa..
com.mysql.cj.jdbc.exceptions.communicationsexception: communications link failure the last packet sent successfully to the server was 0 milliseconds ago. the driv er has not received any packets from the server. ์•ฑ ๋Ÿฐ์นญ์„ ์œ„ํ•ด ์„œ๋ฒ„๋ฅผ ๋ฐฐํฌํ•˜๋˜ ์™€์ค‘ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. Mysql์„ ์„ค์น˜ํ•˜์ง€ ์•Š๊ณ ์„œ๋„, ์ €๋ฒˆ์— ๋ฐฐํฌ๋ฅผ ์„ฑ๊ณตํ–ˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด์œ ๋ฅผ ์•Œ์ง€ ๋ชปํ•˜์˜€๋‹ค. Mysql์„ ๋‹ค์šด ๋ฐ›์•„๋ณด๊ณ , mysql์„ ๋‹ค์šด๋ฐ›์œผ๋‹ˆ localhost์— ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. ์ง€๋‚œ ๋ฐฐํฌ ๋•Œ์—๋Š” ๋”ฐ๋กœ mysql์„ ๋‹ค์šด ๋ฐ›์ง€ ์•Š๊ณ ๋„, ์œ„์™€ ๊ฐ™์€ ์—..
์„œ๋ฒ„์—์„œ ๋ฐฐํฌ๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด redis๊ฐ€ ๋‹ค์šด์ด ๋˜์–ด ์žˆ์ง€ ์•Š์•„ ์—๋Ÿฌ ์ฝ”๋“œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. redis๋ฅผ ์ด์šฉํ•œ ๋กœ๊ทธ์•„์›ƒ์„ ๊ตฌํ˜„ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ubuntu server ํ™˜๊ฒฝ์—์„œ ๋‹ค์šด์„ ๋ฐ›์•„ ์—๋Ÿฌ๋ฅผ ํ•ด๊ฒฐํ•ด์ค˜์•ผ ํ•œ๋‹ค. sudo add-apt-repository ppa:redislabs/redis sudo apt-get update sudo apt-get install redis ์ดํ›„ redis์˜ port๊ฐ€ ์ž˜ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด๋ฉด apt install net-tools netstat -ntlp | grep 6379 ์ž˜ ์ผœ์ ธ ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿผ์—๋„ ์„œ๋ฒ„ ๋‚ด์˜ spring ํ”„๋กœ์ ํŠธ์—์„œ redis ์™€ ๊ด€๋ จ๋œ ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค๋ฉด, spring project applicaiton.properties, or yml..
์•ฑ ๋Ÿฐ์นญ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ, ๋กœ๊ทธ์•„์›ƒ api๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค. JWT๋กœ User์˜ ์ •๋ณด๋ฅผ ์ ‘๊ทผํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋กœ๊ทธ์•„์›ƒ์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” AccessToken์˜ ์‹œ๊ฐ„์„ ๋งŒ๋ฃŒํ•ด์•ผํ–ˆ๋‹ค. ์ƒ์„ฑํ•œ Token์„ ๋งŒ๋ฃŒํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Redis๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ๊ณ , ๋ธ”๋กœ๊ทธ์— ์ž‘์„ฑํ•˜๋ฉฐ ๋ณต์Šตํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. 1. build.gradle implementation 'org.springframework.boot:spring-boot-starter-data-redis' build.gradle์— ์œ„์™€ ๊ฐ™์€ dependencies ์ถ”๊ฐ€ 2. RedisRepositoryConfig @RequiredArgsConstructor @Configuration @EnableRedisRepositories public c..
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int a; try { a = Integer.parseInt(buff..
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); char[] x = scanner.nextLine().toCharArray(); scanner.close(); Arrays.sort(x); for(int j = x.length-1; j>=0 ; j--) { System.out.print(x[j]); } } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) { BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); try { int a = Integer.parseInt(buffer.readLine()); int[] array = new int[a]; for(int i = 0 ; i< a ; i..
chaerlo127
๐Ÿ€ chaeng_ni.develog