알고리즘/백준 알고리즘23 [Baekjoon] 백준 알고리즘: 2512 - 예산 문제링크: https://www.acmicpc.net/problem/2512 input:output:첫번째 나의 풀이import java.util.Arrays;import java.util.Scanner;public class Main { public static void main(String[] args) { Main T = new Main(); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); int[] arr = new int[n]; String s = sc.nextLine(); String[] strings = s.spli.. 2024. 12. 6. [Baekjoon] 백준 알고리즘: 14888 - 연산자 끼어넣기 문제https://www.acmicpc.net/problem/14888 첫번째 나의 풀이import java.util.Scanner;public class Main { static int min = Integer.MAX_VALUE; static int max = Integer.MIN_VALUE; static int calsNum; static int[] cals; static int[] num; public static void main(String[] args) { Main T = new Main(); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.n.. 2024. 12. 5. [Baekjoon] 백준 알고리즘: 1269 - 대칭 차집합 문제 https://www.acmicpc.net/problem/1269 1269번: 대칭 차집합 첫째 줄에 집합 A의 원소의 개수와 집합 B의 원소의 개수가 빈 칸을 사이에 두고 주어진다. 둘째 줄에는 집합 A의 모든 원소가, 셋째 줄에는 집합 B의 모든 원소가 빈 칸을 사이에 두고 각각 주어 www.acmicpc.net 내가 생각했던 풀이과정 1. 집합에 공통 요소가 없기 때문에 리스트 대신 Set 으로 입력받는다. 2. Set의 교집합, 합집합, 차집합, 대칭 차집합 등의 지원해주는 연산자를 통하여 문제를 풀어낸다. 나의 풀이 A, B = map(int, input().split()) A_set = set(map(int, input().split())) B_set = set(map(int, input.. 2021. 11. 23. [Baekjoon] 백준 알고리즘: 1181 - 단어정렬 문제 https://www.acmicpc.net/problem/1181 내가 생각했던 풀이과정 1. 단순하게 리스트 안에 단어가 있다면, 추가를 하지 않는다. 2. sort() 함수를 통해 알파벳으로 정렬 3. sorted 람다 함수를 통해 길이별로 정렬 나의 풀이 N = int(input()) temp = [] for i in range(N): word = input() if word in temp: continue else: temp.append(word) temp.sort() temp = sorted(temp, key = lambda x: len(x)) for i in temp: print(i) 다른 사람의 풀이 words_num = int(input()) words_list = [] for _ i.. 2021. 11. 14. 이전 1 2 3 4 ··· 6 다음