Category: Problems
-
(KOR) 정수 삼각형
Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/1932 Solution Key Points Using brute-force to calculate all possible solutions resulted in duplicate calculations, causing timeout. To avoid timeout, have to use dynamic programming either Bottom-Up or Top-Down
-
(KOR) 로또
Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/6603 Solution Key Points To avoid using the numbers that’s already used, the iteration under backtracking method should start from idx , not 0. ex) for(int i=idx;i<numList.size();i++){ StringBuilder is much faster than System.out.println
-
(KOR)연산자 끼워넣기
Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/14888 Solution Key Points For backtracking method, we need to pass the changed value like the res or numIdx to recursive method as an argument. For full search problems, it’s likely to use DFS
-
(KOR) 스도쿠
Problem – ⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/2580 Solution Key Points Using an array list (zeroList) which stores all empty nodes. Using this, we only need to iterate through this list, NOT the whole grid(9×9). This helps avoid Timeout error. Using a flag(isEnded) to escape when we found the solution. This is required because…
-
(KOR) N-Queen
Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/9663 Solution Key Points The solve method did not require nested for loops like for(int i=0;..){ for(int j=0..){.Instead, we could just pass ‘row’ as an argument and check that row only, because each row can only have 1 Queen at maximum.
-
(KOR) N과 M(4)
Problem – ⭐️⭐️⭐️ https://www.acmicpc.net/problem/15652 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked
-
(KOR) N과 M(3)
Problem – ⭐️⭐️⭐️ https://www.acmicpc.net/problem/15651 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked
-
(KOR) N과 M(2)
Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/15650 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked
-
(KOR) N과 M(1)
Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/15649 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked Backtracking is used when we have to print all or get all cases.
