Deep_Dev
article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 1 : ์‚ผ์ด์‚ฌ

๋ฌธ์ œ ์„ค๋ช… ํ•œ๊ตญ์ค‘ํ•™๊ต์— ๋‹ค๋‹ˆ๋Š” ํ•™์ƒ๋“ค์€ ๊ฐ์ž ์ •์ˆ˜ ๋ฒˆํ˜ธ๋ฅผ ๊ฐ–๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํ•™๊ต ํ•™์ƒ 3๋ช…์˜ ์ •์ˆ˜ ๋ฒˆํ˜ธ๋ฅผ ๋”ํ–ˆ์„ ๋•Œ 0์ด ๋˜๋ฉด 3๋ช…์˜ ํ•™์ƒ์€ ์‚ผ์ด์‚ฌ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 5๋ช…์˜ ํ•™์ƒ์ด ์žˆ๊ณ , ๊ฐ๊ฐ์˜ ์ •์ˆ˜ ๋ฒˆํ˜ธ๊ฐ€ ์ˆœ์„œ๋Œ€๋กœ -2, 3, 0, 2, -5์ผ ๋•Œ, ์ฒซ ๋ฒˆ์งธ, ์„ธ ๋ฒˆ์งธ, ๋„ค ๋ฒˆ์งธ ํ•™์ƒ์˜ ์ •์ˆ˜ ๋ฒˆํ˜ธ๋ฅผ ๋”ํ•˜๋ฉด 0์ด๋ฏ€๋กœ ์„ธ ํ•™์ƒ์€ ์‚ผ์ด์‚ฌ์ž…๋‹ˆ๋‹ค. ๋˜ํ•œ, ๋‘ ๋ฒˆ์งธ, ๋„ค ๋ฒˆ์งธ, ๋‹ค์„ฏ ๋ฒˆ์งธ ํ•™์ƒ์˜ ์ •์ˆ˜ ๋ฒˆํ˜ธ๋ฅผ ๋”ํ•ด๋„ 0์ด๋ฏ€๋กœ ์„ธ ํ•™์ƒ๋„ ์‚ผ์ด์‚ฌ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด ๊ฒฝ์šฐ ํ•œ๊ตญ์ค‘ํ•™๊ต์—์„œ๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์œผ๋กœ ์‚ผ์ด์‚ฌ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•œ๊ตญ์ค‘ํ•™๊ต ํ•™์ƒ๋“ค์˜ ๋ฒˆํ˜ธ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ •์ˆ˜ ๋ฐฐ์—ด number๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ํ•™์ƒ๋“ค ์ค‘ ์‚ผ์ด์‚ฌ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์˜ ์ˆ˜๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•˜์„ธ..

[SWEA][JAVA] ์•ŒํŒŒ๋ฒณ ๊ณต๋ถ€

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYLnMQT6vPADFATf SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com ์ˆœ์„œ๊ฐ€ a๋ถ€ํ„ฐ ์ˆœ์„œ๋Œ€๋กœ ์ผ์น˜ํ•˜๋Š” ์•ŒํŒŒ๋ฒณ์˜ ๊ฐœ์ˆ˜๋กœ ์ง€์ •ํ•ด์คฌ๊ธฐ๋•Œ๋ฌธ์— ์–ด๋ ต์ง€์•Š์•˜์Œ. import java.util.Scanner; import java.io.FileInputStream; class Solution{ public static void main(String args[]) throws Exception{ Scanner kb=new Scanner(System.in); int n=kb.nextI..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 1 : ๋ชจ์˜๊ณ ์‚ฌ (์™„์ „ํƒ์ƒ‰)

๋ฌธ์ œ ์„ค๋ช… ์ˆ˜ํฌ์ž๋Š” ์ˆ˜ํ•™์„ ํฌ๊ธฐํ•œ ์‚ฌ๋žŒ์˜ ์ค€๋ง์ž…๋‹ˆ๋‹ค. ์ˆ˜ํฌ์ž ์‚ผ์ธ๋ฐฉ์€ ๋ชจ์˜๊ณ ์‚ฌ์— ์ˆ˜ํ•™ ๋ฌธ์ œ๋ฅผ ์ „๋ถ€ ์ฐ์œผ๋ ค ํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜ํฌ์ž๋Š” 1๋ฒˆ ๋ฌธ์ œ๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰ ๋ฌธ์ œ๊นŒ์ง€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฐ์Šต๋‹ˆ๋‹ค. 1๋ฒˆ ์ˆ˜ํฌ์ž๊ฐ€ ์ฐ๋Š” ๋ฐฉ์‹: 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ... 2๋ฒˆ ์ˆ˜ํฌ์ž๊ฐ€ ์ฐ๋Š” ๋ฐฉ์‹: 2, 1, 2, 3, 2, 4, 2, 5, 2, 1, 2, 3, 2, 4, 2, 5, ... 3๋ฒˆ ์ˆ˜ํฌ์ž๊ฐ€ ์ฐ๋Š” ๋ฐฉ์‹: 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, ... 1๋ฒˆ ๋ฌธ์ œ๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰ ๋ฌธ์ œ๊นŒ์ง€์˜ ์ •๋‹ต์ด ์ˆœ์„œ๋Œ€๋กœ ๋“ค์€ ๋ฐฐ์—ด answers๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ๊ฐ€์žฅ ๋งŽ์€ ๋ฌธ์ œ๋ฅผ ๋งžํžŒ ์‚ฌ๋žŒ์ด ๋ˆ„๊ตฌ์ธ์ง€ ๋ฐฐ์—ด์— ๋‹ด์•„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์ž‘..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ์†Œ์ธ์ˆ˜๋ถ„ํ•ด ( *์†Œ์ธ์ˆ˜๋ถ„ํ•ด )

๋ฌธ์ œ ์„ค๋ช… ์†Œ์ธ์ˆ˜๋ถ„ํ•ด๋ž€ ์–ด๋–ค ์ˆ˜๋ฅผ ์†Œ์ˆ˜๋“ค์˜ ๊ณฑ์œผ๋กœ ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด 12๋ฅผ ์†Œ์ธ์ˆ˜ ๋ถ„ํ•ดํ•˜๋ฉด 2 * 2 * 3 ์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 12์˜ ์†Œ์ธ์ˆ˜๋Š” 2์™€ 3์ž…๋‹ˆ๋‹ค. ์ž์—ฐ์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ n์˜ ์†Œ์ธ์ˆ˜๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ๋‹ด์€ ๋ฐฐ์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. ์ œํ•œ์‚ฌํ•ญ 2 ≤ n ≤ 10,000 ์ž…์ถœ๋ ฅ ์˜ˆnresult 12 [2, 3] 17 [17] 420 [2, 3, 5, 7] ์†Œ์ธ์ˆ˜๋ถ„ํ•ด ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐ€์žฅ ์‰ฌ์šด ๋ฐฉ๋ฒ•์€ 2๋ถ€ํ„ฐ N๊นŒ์ง€ ๋ชจ๋“  ์ˆ˜๋ฅผ ๋‚˜๋ˆ ๋ณด๋ฉด์„œ ๋‚˜๋จธ์ง€๊ฐ€ 0์ผ ๊ฒฝ์šฐ ๊ทธ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ฆ‰, ์•„๋ž˜์™€ ๊ฐ™์ด ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค. ( 1์€ ์†Œ์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ฏ€๋กœ ๋‹น์—ฐํžˆ ์ œ์™ธ ) for(int i=2; i

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

๋ฌธ์ œ ์„ค๋ช… ๋ฌธ์ž์—ด my_str๊ณผ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, my_str์„ ๊ธธ์ด n์”ฉ ์ž˜๋ผ์„œ ์ €์žฅํ•œ ๋ฐฐ์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. ์ œํ•œ์‚ฌํ•ญ 1 ≤ my_str์˜ ๊ธธ์ด ≤ 100 1 ≤ n ≤ my_str์˜ ๊ธธ์ด my_str์€ ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž, ๋Œ€๋ฌธ์ž, ์ˆซ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆmy_strnresult "abc1Addfggg4556b" 6 ["abc1Ad", "dfggg4", "556b"] "abcdef123" 3 ["abc", "def", "123"] * ๋ฌธ์ œ ์ž์ฒด๋Š” ์–ด๋ ต์ง€ ์•Š์€๋ฐ, ์ฒ˜์Œ์— ์ถœ๋ ฅํ• ๋•Œ ์ž๊พธ ์ž๋ฅธ ๋ฐฐ์—ด์•ž์— null ๋ฌธ์ž์—ด์ด ๊ฐ™์ด ์ถœ๋ ฅ๋ผ์„œ ๋ญ๊ฐ€๋ฌธ์ œ์ง€ ํ•ด์„œ ๊ตฌ๊ธ€๋งํ•ด๋ดค๋”๋‹ˆ String ๋ฐฐ์—ด์„ ""๋กœ ์ดˆ๊ธฐํ™” ํ›„์— ์‚ฌ์šฉํ•ด์•ผํ–ˆ๋‹ค. public class Solu..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ๋ฐฐ์—ด ํšŒ์ „์‹œํ‚ค๊ธฐ

๋ฌธ์ œ ์„ค๋ช… ์ •์ˆ˜๊ฐ€ ๋‹ด๊ธด ๋ฐฐ์—ด numbers์™€ ๋ฌธ์ž์—ด direction๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ๋ฐฐ์—ด numbers์˜ ์›์†Œ๋ฅผ direction๋ฐฉํ–ฅ์œผ๋กœ ํ•œ ์นธ์”ฉ ํšŒ์ „์‹œํ‚จ ๋ฐฐ์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. ์ œํ•œ์‚ฌํ•ญ 3 ≤ numbers์˜ ๊ธธ์ด ≤ 20 direction์€ "left" ์™€ "right" ๋‘˜ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆnumbersdirectionresult [1, 2, 3] "right" [3, 1, 2] [4, 455, 6, 4, -1, 45, 6] "left" [455, 6, 4, -1, 45, 6, 4] ์ฒซ๊ฐ’ or ๋งˆ์ง€๋ง‰ ๊ฐ’๋งŒ ๋”ฐ๋กœ ์ €์žฅํ•ด๋‘๊ณ  ๋ฐฐ์—ด ํšŒ์ „๋งŒ ์‹œํ‚ค๋ฉด ๋˜๋Š” ๋ฌธ์ œ class Solution { public int[] solution(int[] number..

[SWEA][JAVA] ํ™€์ˆ˜๋งŒ ๋”ํ•˜๊ธฐ

๋ฌธ์ œ ๋งํฌ https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QSEhaA5sDFAUq SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner kb=new Scanner(System.in); int T=kb.nextInt(); int[][] arr=new int[T][10]; fo..

[SWEA][JAVA][S/W ๋ฌธ์ œํ•ด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - ์ตœ๋นˆ์ˆ˜ ๊ตฌํ•˜๊ธฐ

๋ฌธ์ œ๋งํฌ : https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV13zo1KAAACFAYh SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner kb=new Scanner(System.in); int T=kb.nextInt(); for(int test_case=1; test_cas..