Deep_Dev
article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ๋‹คํ•ญ์‹ ๋”ํ•˜๊ธฐ

์ฃผ์˜ํ•ด์•ผ ํ•  ๊ฒƒ์€.. 1x๋Š” x๋กœ ๋‚˜์™€์•ผ ํ•œ๋‹ค๋Š”๊ฒƒ.. ์ถœ๋ ฅ๋ฌธ์ด ๋”๋Ÿฝ์ง€๋งŒ..... class Solution { public String solution(String polynomial) { String answer = ""; String[] arr=polynomial.split(" \\+ "); int xSum=0; int Sum=0; for(String x:arr){ if(x.contains("x")){ if(x.length()==1){ xSum+=1; }else { String temp = x.replace("x",""); xSum+=Integer.parseInt(temp); } }else{ Sum+=Integer.parseInt(x); } } if(xSum==0&&Sum!=0) answer=Stri..

article thumbnail
[๋ฐฑ์ค€][JAVA]1181๋ฒˆ : ๋‹จ์–ด ์ •๋ ฌ

๋จผ์ € ๋ฐฐ์—ด์— ๋ชจ๋“  ์›์†Œ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์ €์žฅํ•˜๊ณ  sort() ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์œ„์—์„œ ๋ฐฐ์› ๋˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ†ตํ•ด ์ •๋ ฌ์„ ํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ธธ์ด ์ˆœ์œผ๋กœ ์ •๋ ฌ์ด ๋˜๊ณ  ๊ธธ์ด๊ฐ€ ๊ฐ™์„ ๊ฒฝ์šฐ๋Š” ์‚ฌ์ „ ์ˆœ์œผ๋กœ ์ •๋ ฌ์ด ๋œ๋‹ค. ์ด๋•Œ ์ถœ๋ ฅํ•  ๋•Œ์—๋Š” ์ •๋ ฌ๋œ ๋ฐฐ์—ด์—์„œ ์ถœ๋ ฅํ•˜๋ ค๋Š” ๋ฌธ์ž์—ด์ด ์ง์ „ ๋ฐฐ์—ด์— ์žˆ๋Š” ๋ฌธ์ž์—ด๊ณผ ๊ฐ™์ง€ ์•Š์„ ๊ฒฝ์šฐ๋งŒ ์ถœ๋ ฅํ•˜์—ฌ ๋ฌธ์ œ์˜ ์กฐ๊ฑด๋Œ€๋กœ '์ค‘๋ณต๋˜๋Š” ๋ฌธ์ž์—ด์€ ํ•œ ๋ฒˆ๋งŒ ์ถœ๋ ฅ'ํ•˜๋„๋ก ํ•œ๋‹ค. import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb = new Scanner(System.in); int N=kb.nextInt(); String[] arr=new String[N]; kb.nextLine(..

article thumbnail
[๋ฐฑ์ค€][JAVA]2101๋ฒˆ : ํ†ต๊ณ„ํ•™

์ตœ๋นˆ๊ฐ’๋งŒ ์œ ์˜ํ•ด์„œ ๊ตฌํ•˜๋ฉด ๋œ๋‹ค. ์ตœ๋นˆ๊ฐ’์ด 2๊ฐœ ์ด์ƒ์ผ๋•Œ๋Š” 2๋ฒˆ์งธ๋กœ ์ž‘์€๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š”๊ฒƒ์ด๊ณ , ์Œ์ˆ˜๊ฐ€ ๋“ค์–ด์˜ฌ ์ˆ˜๋„ ์žˆ๊ธฐ์— 1์ฐจ์› ๋ฐฐ์—ด์„ ์ƒ์„ฑํ•ด์„œ ๋นˆ๋„์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ๋ฐฉ์‹์€ ์•ˆ๋œ๋‹ค. import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb = new Scanner(System.in); int n=kb.nextInt(); int[] arr=new int[n]; int[][] cnt=new int[4001][2]; // ์ตœ๋นˆ๊ฐ’ ๊ตฌํ•  2์ฐจ์›๋ฐฐ์—ด ( ์–‘์ˆ˜:0์—ด ์Œ์ˆ˜:1์—ด ) int sum=0; int max=Integer.MIN_VALUE; // ์ตœ๋Œ€๊ฐ’ ์ฐพ๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ for(int i=0; i0..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ํŠน์ดํ•œ ์ •๋ ฌ

import java.util.*; class Solution { public int[] solution(int[] numlist, int n) { int[] answer=new int[numlist.length]; ArrayList list=new ArrayList(); for(int i=0; ib){ return -1; }else{ return 1; } }else{ return absA-absB; } } }); for(int i=0; i

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ์น˜ํ‚จ์ฟ ํฐ

๊ทธ๋ƒฅ ๊ตฌํ˜„๋ฌธ์ œ.. import java.util.*; class Main { public int solution(int chicken) { int answer = 0; int temp = 0; while (chicken >= 10) { answer += chicken / 10; temp = chicken % 10; chicken = chicken / 10 + temp; } return answer; } }

[๋ฐฑ์ค€][JAVA]15829๋ฒˆ : Hashing

Hashing ๋ถ€๋ถ„ ์„ฑ๊ณต์„œ๋ธŒํƒœ์Šคํฌ ์‹œ๊ฐ„ ์ œํ•œ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ์ œ์ถœ์ •๋‹ต๋งžํžŒ ์‚ฌ๋žŒ์ •๋‹ต ๋น„์œจ 1 ์ดˆ 512 MB 32492 10101 8685 30.995% ๋ฌธ์ œ APC์— ์˜จ ๊ฒƒ์„ ํ™˜์˜ํ•œ๋‹ค. ๋งŒ์•ฝ ์—ฌ๋Ÿฌ๋ถ„์ด ํ•™๊ต์—์„œ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ˆ˜๊ฐ•ํ–ˆ๋‹ค๋ฉด ํ•ด์‹œ ํ•จ์ˆ˜์— ๋Œ€ํ•ด ๋ฐฐ์› ์„ ๊ฒƒ์ด๋‹ค. ํ•ด์‹œ ํ•จ์ˆ˜๋ž€ ์ž„์˜์˜ ๊ธธ์ด์˜ ์ž…๋ ฅ์„ ๋ฐ›์•„์„œ ๊ณ ์ •๋œ ๊ธธ์ด์˜ ์ถœ๋ ฅ์„ ๋‚ด๋ณด๋‚ด๋Š” ํ•จ์ˆ˜๋กœ ์ •์˜ํ•œ๋‹ค. ํ•ด์‹œ ํ•จ์ˆ˜๋Š” ๋ฌด๊ถ๋ฌด์ง„ํ•œ ์‘์šฉ ๋ถ„์•ผ๋ฅผ ๊ฐ–๋Š”๋ฐ, ๋Œ€ํ‘œ์ ์œผ๋กœ ์ž๋ฃŒ์˜ ์ €์žฅ๊ณผ ํƒ์ƒ‰์— ์“ฐ์ธ๋‹ค. ์ด ๋ฌธ์ œ์—์„œ๋Š” ์—ฌ๋Ÿฌ๋ถ„์ด ์•ž์œผ๋กœ ์œ ์šฉํ•˜๊ฒŒ ์“ธ ์ˆ˜ ์žˆ๋Š” ํ•ด์‹œ ํ•จ์ˆ˜๋ฅผ ํ•˜๋‚˜ ๊ฐ€๋ฅด์ณ์ฃผ๊ณ ์ž ํ•œ๋‹ค. ๋จผ์ €, ํŽธ์˜์ƒ ์ž…๋ ฅ์œผ๋กœ ๋“ค์–ด์˜ค๋Š” ๋ฌธ์ž์—ด์—๋Š” ์˜๋ฌธ ์†Œ๋ฌธ์ž(a, b, ..., z)๋กœ๋งŒ ๊ตฌ์„ฑ๋˜์–ด์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. ์˜์–ด์—๋Š” ์ด 26๊ฐœ์˜ ์•ŒํŒŒ๋ฒณ์ด ์กด์žฌํ•˜๋ฏ€๋กœ a์—๋Š” 1, b์—๋Š” 2, c์—๋Š” 3, ...

article thumbnail
[๋ฐฑ์ค€][JAVA]2609๋ฒˆ : ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜

์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ ---> ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ• ๐Ÿ’ก ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); } ๐Ÿ’ก ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ a*b / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb = new Scanner(System.in); int a = kb.nextInt(); int b = kb.nextInt(); int max=gcd(a,b); // ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ int min=(a*b)/max; System.out.println(max); System.out.print(min); } static int g..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ์บ๋ฆญํ„ฐ์˜ ์ขŒํ‘œ

keyinput.length ๋งŒํผ ๋ฐ˜๋ณต๋ฌธ์—์„œ ์กฐ๊ฑด๋ฌธ๋งŒ ์ž˜ ๊ฑธ์–ด์ฃผ๋ฉด ํ•ด๊ฒฐ๋˜๋Š” ๋ฌธ์ œ ์ฃผ์˜ํ• ์ ์€ ์ฃผ์–ด์ง„ board๊ธธ์ด/2 ์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’๊นŒ์ง€๋งŒ ์›€์ง์ผ ์ˆ˜ ์žˆ๋‹ค๋Š”๊ฒƒ ( ์Œ์ˆ˜ ์ฒ˜๋ฆฌ ์‹ ๊ฒฝ์“ฐ๊ธฐ ) class Solution { public int[] solution(String[] keyinput, int[] board) { int[] answer = {0,0}; for(int i=0; i answer[0] if(keyinput[i].equals("left")||keyinput[i].equals("right")){ if(keyinput[i].equals("left")){ if(answer[0]>-(board[0]/2)) answer[0]--; }else{ if(answer[0] answer[1] }else{ if(k..