[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv2] ์˜ฌ๋ฐ”๋ฅธ ๊ด„ํ˜ธ | ์ž๋ฐ”
ยท
๐Ÿ“ Coding Test/Programmers Lv2
๋ฌธ์ œ์˜ฌ๋ฐ”๋ฅธ ๊ด„ํ˜ธํ’€์ด 1import java.util.*;class Solution { boolean solution(String s) { String[] strArr = s.split(""); Stack stack = new Stack(); for(int i = 0; i ์ •ํ™•์„ฑ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ†ต๊ณผํ–ˆ์ง€๋งŒ, ํšจ์œจ์„ฑ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ํ†ต๊ณผํ•˜๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.์ด ๋ฌธ์ œ์˜ ์กฐ๊ฑด ์ค‘ ํ•˜๋‚˜๋Š” ๋ฌธ์ž์—ด์ด ์ตœ๋Œ€ 100,000์ด ๋ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ด๊ณ , split์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฌธ์ž์—ด ์ „์ฒด๋ฅผ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด๋กœ ๋ณต์‚ฌํ•ด์•ผ ํ•˜๋ฉฐ, ์ถ”๊ฐ€์ ์ธ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๊ณผ ์ฒ˜๋ฆฌ ์‹œ๊ฐ„์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.ํ’€์ด 2class Solution { boolean solution(String s) { String[] ..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv2] ๊ฒŒ์ž„ ๋งต ์ตœ๋‹จ๊ฑฐ๋ฆฌ | ์ž๋ฐ”
ยท
๐Ÿ“ Coding Test/Programmers Lv2
๋ฌธ์ œ๊ฒŒ์ž„ ๋งต ์ตœ๋‹จ๊ฑฐ๋ฆฌํ’€์ดimport java.util.*;class Solution { public int solution(int[][] maps) { int[][] visited = new int[maps.length][maps[0].length]; int[] dx = {1, -1, 0, 0}; int[] dy = {0, 0, 1, -1}; bfs(new int[]{0, 0}, maps, visited, dx, dy); int answer = visited[maps.length - 1][maps[0].length - 1]; return answer == 0 ? -1 : answer; } void bfs(int[]..