๋ฌธ์ ์ ์๋ฅผ ์ ์ฅํ๋ ์คํ์ ๊ตฌํํ ๋ค์, ์ ๋ ฅ์ผ๋ก ์ฃผ์ด์ง๋ ๋ช ๋ น์ ์ฒ๋ฆฌํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. ๋ช ๋ น์ ์ด ๋ค์ฏ ๊ฐ์ง์ด๋ค. push X: ์ ์ X๋ฅผ ์คํ์ ๋ฃ๋ ์ฐ์ฐ์ด๋ค. pop: ์คํ์์ ๊ฐ์ฅ ์์ ์๋ ์ ์๋ฅผ ๋นผ๊ณ , ๊ทธ ์๋ฅผ ์ถ๋ ฅํ๋ค. ๋ง์ฝ ์คํ์ ๋ค์ด์๋ ์ ์๊ฐ ์๋ ๊ฒฝ์ฐ์๋ -1์ ์ถ๋ ฅํ๋ค. size: ์คํ์ ๋ค์ด์๋ ์ ์์ ๊ฐ์๋ฅผ ์ถ๋ ฅํ๋ค. empty: ์คํ์ด ๋น์ด์์ผ๋ฉด 1, ์๋๋ฉด 0์ ์ถ๋ ฅํ๋ค. top: ์คํ์ ๊ฐ์ฅ ์์ ์๋ ์ ์๋ฅผ ์ถ๋ ฅํ๋ค. ๋ง์ฝ ์คํ์ ๋ค์ด์๋ ์ ์๊ฐ ์๋ ๊ฒฝ์ฐ์๋ -1์ ์ถ๋ ฅํ๋ค. ์ ๋ ฅ ์ฒซ์งธ ์ค์ ์ฃผ์ด์ง๋ ๋ช ๋ น์ ์ N (1 ≤ N ≤ 10,000)์ด ์ฃผ์ด์ง๋ค. ๋์งธ ์ค๋ถํฐ N๊ฐ์ ์ค์๋ ๋ช ๋ น์ด ํ๋์ฉ ์ฃผ์ด์ง๋ค. ์ฃผ์ด์ง๋ ์ ์๋ 1๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ๊ณ , 100,000๋ณด..

ํ๊ธ ํ์ฅ ์๋๊ทธ๋จ(HashMap) ๋งค์ถ์ก์ ์ข ๋ฅ(Hash, sliding window) ๋ชจ๋ ์๋๊ทธ๋จ ์ฐพ๊ธฐ ( Hash, sliding window : ์๊ฐ๋ณต์ก๋ O(n)) K๋ฒ์งธ ํฐ ์ 1. ํ๊ธํ์ฅ import java.util.*; public class Main { public char solution(int n,String str){ char answer=' '; HashMap map=new HashMap(); for(char x:str.toCharArray()){ map.put(x,map.getOrDefault(x,0)+1); } int max=Integer.MIN_VALUE; for(char key:map.keySet()){ if(map.get(key)>max){ max=map.get(ke..

1. ๋ ๋ฐฐ์ด ํฉ์น๊ธฐ ( two pointers algorithm ) 2. ๊ณตํต์์๊ตฌํ๊ธฐ( two points algorithm ) 3. ์ต๋ ๋งค์ถ( Sliding window ) 4. ์ฐ์๋ถ๋ถ์์ด ( ๋ณตํฉ์ ๋ฌธ์ ) 5.1 ์ฐ์๋ ์์ฐ์์ ํฉ ( two pointers ) 5.2 ์ฐ์๋ ์์ฐ์์ ํฉ ( ์ํ ) 6. ์ต๋ ๊ธธ์ด ์ฐ์๋ถ๋ถ์์ด ( ๋ณตํฉ์ ๋ฌธ์ ) 1. ๋ ๋ฐฐ์ด ํฉ์น๊ธฐ ( two pointers algorithm ) import java.util.*; public class Main { public ArrayList solution(int n, int m, int[] a, int[] b){ ArrayList answer=new ArrayList(); int p1=0, p2=0; while(p1

1. ๋ฌธ์์ฐพ๊ธฐ import java.util.Scanner; public class Main { public int solution(String str, char t){ int answer=0; str=str.toUpperCase(); t=Character.toUpperCase(t); for(int i=0; im){ // ์ต๋๊ฐ ์๊ณ ๋ฆฌ์ฆ m=len; answer=x; } } return answer; } public static void main(String[] args){ Main T = new Main(); Scanner kb = new Scanner(System.in); String str = kb.nextLine(); System.out.print(T.solution(str); } } 4. ๋จ์ด ..

2.1 ํฐ ์ ์ถ๋ ฅํ๊ธฐ solution import java.util.*; class Main { public ArrayList solution(int n, int[] arr){ ArrayList answer = new ArrayList(); answer.add(arr[0]); for(int i=1; iarr[i-1]) answer.add(arr[i]); } return answer; } public static void main(String[] args) { Main T = new Main(); Scanner kb = new Scanner(System.in); int n = kb.nextInt(); int[] arr = new int[n]; for(int i=0; i