Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- javascript
- 99클럽
- jsp
- generic class
- 99클럽 #코딩테스트준비 #개발자취업 #항해99 #til
- 정렬
- DB
- 공개키 암호화
- 코딩테스트
- 항해99
- spring
- Sort
- 위상정렬
- 자료구조
- LeetCode
- js
- Java
- 개발자취업
- 가상컴퓨팅
- mysql
- 코딩테스트준비
- python
- sql
- 크루스칼
- Algorithm
- 알고리즘
- JPA
- til
- dbms
- 코테
Archives
- Today
- Total
PLOD
[백준] 평행선(2358) 본문
🔗 문제 링크
https://www.acmicpc.net/problem/2358
✅ 코드
package test.silver;
import java.util.*;
import java.io.*;
public class 백준_2358 {
static int n;
static HashMap<Integer, Integer> xMap;
static HashMap<Integer, Integer> yMap;
public static void main(String[] args) throws Exception{
int answer = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
xMap = new HashMap<>();
yMap = new HashMap<>();
for(int i = 0; i < n ; i++){
st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
xMap.put(x, xMap.getOrDefault(x, 0) + 1);
yMap.put(y, yMap.getOrDefault(y, 0) + 1);
}
for (int count : xMap.values()) {
if (count >= 2) {
answer++;
}
}
for (int count : yMap.values()) {
if (count >= 2) {
answer++;
}
}
System.out.println(answer);
br.close();
}
}
💡 배운 점 & 느낀 점
StringTokenizer → 문자열을 공백단위로 이어서 입력받을 때 사용합니다(Python의 split() 과 같은 역할임)
'대외 활동 및 IT 지식 > 알고리즘 문제 풀이 정리' 카테고리의 다른 글
| [백준] 단어 정렬(1181) (0) | 2026.04.10 |
|---|---|
| [Programmers] 조건에 맞는 개발자 찾기(MySQL) (0) | 2026.03.23 |
| [Leetcode] 187. Repeated DNA Sequences (0) | 2026.03.23 |
| [Leetcode] 2283. Check if Number Has Equal Digit Count and Digit Value (0) | 2026.03.20 |
| [백준] 좌표 압축(18870) (0) | 2026.03.09 |
Comments