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

ํ˜•๋ณ€ํ™˜๋งŒ ์ž˜ํ•ด์„œ ํ’€์–ด์ฃผ๋ฉด ๋œ๋‹ค. ์ฒซ๋ฒˆ์งธ ์ฝ”๋“œ import java.math.BigInteger; class Solution { public String solution(String bin1, String bin2) { String answer = ""; BigInteger a=new BigInteger(bin1,2); BigInteger b=new BigInteger(bin2, 2); BigInteger sum=a.add(b); answer=sum.toString(2); return answer; } } ์กฐ๊ธˆ ๋” ์งง๊ฒŒ ๋ฐ”๊พผ ๋‘๋ฒˆ์งธ ์ฝ”๋“œ import java.math.BigInteger; class Solution { public String solution(String bin1, String bin2) ..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ๊ตฌ์Šฌ์„ ๋‚˜๋ˆ„๋Š” ๊ฒฝ์šฐ์˜ ์ˆ˜ ( *DFS, ๋ฉ”๋ชจ์ด์ œ์ด์…˜ )

n๊ฐœ์ค‘์—์„œ r๊ฐœ๋ฅผ ์„ ํƒํ•˜๋Š” ์กฐํ•ฉ ๋ฐฉ๋ฒ•.. nCr => n-1Cr + n-1Cr-1 .. DFS ์ด์šฉํ•ด์„œ ํ’€์ด. class Solution { int[][] dy=new int[31][31]; public int DFS(int n, int r){ if(dy[n][r]>0) return dy[n][r]; if(r==0||n==r){ return 1; }else return DFS(n-1,r-1)+DFS(n-1,r); } public int solution(int balls, int share) { return DFS(balls, share); } }

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ๋ฌธ์ž์—ด ๋ฐ€๊ธฐ

StringBuilder ์ด์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค. insert( ์‚ฝ์ž… ์œ„์น˜, ์‚ฝ์ž… ๋ฌธ์ž์—ด) deleteCharAt(ํ•ด๋‹น ์ธ๋ฑ์Šค ๋ฌธ์ž ์‚ญ์ œ) ์ฒ˜์Œ ์‚ฌ์šฉํ•ด๋ดค๋‹ค. class Solution { public int solution(String a, String b) { int answer = 0; StringBuilder sb = new StringBuilder(a); for (int i = 0; i < a.length(); i++) { if(b.equals(sb.toString())){ break; }else{ //hello char c=sb.charAt(a.length()-1); sb.deleteCharAt(a.length()-1); sb.insert(0,c); answer++; } } if(answer==a.le..

article thumbnail
[๋ฐฑ์ค€][JAVA]2805๋ฒˆ : ๋‚˜๋ฌด ์ž๋ฅด๊ธฐ ( ์ด๋ถ„๊ฒ€์ƒ‰ )

๋ฐฐ์—ด ์š”์†Œ๋ฅผ ๋ณ€์ˆ˜ ํ•˜๋‚˜๋ฅผ ์ด์šฉํ•ด์„œ ๊ณ„์† ๋ฐ˜๋ณต๋ฌธ ๋Œ๋ฆฌ๋ฉด ์—ญ์‹œ ์‹œ๊ฐ„์ดˆ๊ณผ๋‹ค . ์‹œ๊ฐ„์„ ๋‹จ์ถ•ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ด๋ถ„๊ฒ€์ƒ‰์„ ์ด์šฉํ•ด์•ผ ํ•œ๋‹ค. sum rt ๊ฐ์†Œ sum > m ์ด๋ฉด , ๋ชฉํ‘œ๋Ÿ‰๋ณด๋‹ค ๋งŽ์€๊ฑฐ๋‹ˆ ๋” ์ ๊ฒŒ ์ž˜๋ผ์•ผํ•จ -> lt ์ฆ๊ฐ€ import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb = new Scanner(System.in); int n=kb.nextInt(); int m=kb.nextInt(); int[] arr=new int[n]; int lt=0; int rt=0; // ์ตœ์ €๊ฐ’ lt : ์ตœ๋Œ€๊ฐ’ rt for(int i=0; i

article thumbnail
์„น์…˜8. DFS, BFS ํ™œ์šฉ

1. ํ•ฉ์ด ๊ฐ™์€ ๋ถ€๋ถ„์ง‘ํ•ฉ 2. ๋ฐ”๋‘‘์ด ์Šน์ฐจ 3. ์ตœ๋Œ€์ ์ˆ˜ ๊ตฌํ•˜๊ธฐ 4. ์ค‘๋ณต์ˆœ์—ด(์ฑ„์ ์ง€์›์•ˆ๋จ) 5. ๋™์ „๊ตํ™˜ 6. ์ˆœ์—ด ๊ตฌํ•˜๊ธฐ(์ฑ„์ ์ง€์›์•ˆ๋จ) 7. ์กฐํ•ฉ์ˆ˜(๋ฉ”๋ชจ์ด์ œ์ด์…˜) 8. ์ˆ˜์—ด ์ถ”์ธกํ•˜๊ธฐ 9. ์กฐํ•ฉ ๊ตฌํ•˜๊ธฐ(์ฑ„์ ์ง€์›์•ˆ๋จ) 10. ๋ฏธ๋กœํƒ์ƒ‰(DFS) 11. ๋ฏธ๋กœ์˜ ์ตœ๋‹จ๊ฑฐ๋ฆฌ ํ†ต๋กœ(BFS) 12. ํ† ๋งˆํ† (BFS) 13. ์„ฌ๋‚˜๋ผ ์•„์ผ๋žœ๋“œ(DFS) 14. ์„ฌ๋‚˜๋ผ ์•„์ผ๋žœ๋“œ(BFS) 15. ํ”ผ์ž๋ฐฐ๋‹ฌ๊ฑฐ๋ฆฌ(DFS) 1. ํ•ฉ์ด ๊ฐ™์€ ๋ถ€๋ถ„์ง‘ํ•ฉ 2. ๋ฐ”๋‘‘์ด ์Šน์ฐจ 3. ์ตœ๋Œ€์ ์ˆ˜ ๊ตฌํ•˜๊ธฐ 4. ์ค‘๋ณต ์ˆœ์—ด ๊ตฌํ•˜๊ธฐ 5. ๋™์ „ ๊ตํ™˜ 6. ์ˆœ์—ด ๊ตฌํ•˜๊ธฐ 7. ์กฐํ•ฉ์ˆ˜ ( ๋ฉ”๋ชจ์ด์ œ์ด์…˜ ) 8. ์ˆ˜์—ด ์ถ”์ธกํ•˜๊ธฐ ( ๋ฉ”๋ชจ์ด์ œ์ด์…˜ + DFS ) 9. ์กฐํ•ฉ ๊ตฌํ•˜๊ธฐ

์„น์…˜7. Recursive, Tree, Graph(DFS, BFS ๊ธฐ์ดˆ)

๐Ÿ’ก Recursive, Tree, Graph(DFS, BFS ๊ธฐ์ดˆ) 1. ์žฌ๊ท€ํ•จ์ˆ˜(์Šคํƒํ”„๋ ˆ์ž„) 2. ์ด์ง„์ˆ˜ ์ถœ๋ ฅ(์žฌ๊ท€) 3. ํŒฉํ† ๋ฆฌ์–ผ 4. ํ”ผ๋ณด๋‚˜์น˜ ์žฌ๊ท€(๋ฉ”๋ชจ์ด์ œ์ด์…˜) 5. ์ด์ง„ํŠธ๋ฆฌ์ˆœํšŒ(DFS : Depth-First Search) 6. ๋ถ€๋ถ„์ง‘ํ•ฉ ๊ตฌํ•˜๊ธฐ(DFS) 7. ์ด์ง„ํŠธ๋ฆฌ ๋ ˆ๋ฒจํƒ์ƒ‰(BFS : Breadth-First Search) 8. ์†ก์•„์ง€ ์ฐพ๊ธฐ1(BFS) 9. Tree ๋ง๋‹จ๋…ธ๋“œ๊นŒ์ง€์˜ ๊นŒ์žฅ ์งง์€ ๊ฒฝ๋กœ(DFS) 10. Tree ๋ง๋‹จ๋…ธ๋“œ๊นŒ์ง€์˜ ๊นŒ์žฅ ์งง์€ ๊ฒฝ๋กœ(BFS) 11. ๊ทธ๋ž˜ํ”„์™€ ์ธ์ ‘ํ–‰๋ ฌ 12. ๊ฒฝ๋กœํƒ์ƒ‰(DFS) 13. ๊ฒฝ๋กœํƒ์ƒ‰(์ธ์ ‘๋ฆฌ์ŠคํŠธ, ArrayList) 14. ๊ทธ๋ž˜ํ”„ ์ตœ๋‹จ๊ฑฐ๋ฆฌ(BFS)

article thumbnail
์„น์…˜6. Sorting and Searching(์ •๋ ฌ, ์ด๋ถ„๊ฒ€์ƒ‰๊ณผ ๊ฒฐ์ •์•Œ๊ณ ๋ฆฌ์ฆ˜)

๐Ÿ“š ์ •๋ ฌ / ์ด๋ถ„๊ฒ€์ƒ‰ & ๊ฒฐ์ • ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์„ ํƒ ์ •๋ ฌ import java.util.*; class Solution { public int[] solution(int n, int[] arr) { for(int i=0; i

article thumbnail
[๋ฐฑ์ค€][JAVA]2231๋ฒˆ : ๋ถ„ํ•ดํ•ฉ

๊ฐ€์žฅ ์ž‘์€ ์ƒ์„ฑ์ž๋ฅผ ๊ตฌํ•˜๋Š”๊ฑฐ๋‹ˆ๊นŒ , 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์„œ ์ƒ์„ฑ์ž๋ฅผ ์ฐพ๋Š”์ˆœ๊ฐ„ ์ถœ๋ ฅํ•˜๋ฉด ๋œ๋‹ค. ๋ธŒ๋ฃจํŠธํฌ์Šค๋ฅผ ์ด์šฉํ–ˆ๋‹ค. ๊ธฐ์กด ๊ฐ’ + ์ž๋ฆฟ์ˆ˜ ๋”ํ•˜๊ธฐ๋ฅผ ์ด์šฉํ•ด์„œ ์ž…๋ ฅ๋ฐ›์€ n๊ณผ ๋™์ผํ•˜๋ฉด ๊ทธ๊ฒŒ ์ƒ์„ฑ์ž์ด๋‹ค. import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb=new Scanner(System.in); int n=kb.nextInt(); int answer=0; for(int i=0; i