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 |
Tags
- 정렬
- 누적 합
- 그래프
- 유니온 파인드
- 그리디 알고리즘
- ue5
- 재귀
- 유니티
- 브루트포스
- 백준
- 트리
- XR Interaction Toolkit
- 시뮬레이션
- 다익스트라
- c++
- DFS
- 투 포인터
- 우선순위 큐
- 알고리즘
- 스택
- 수학
- 다이나믹 프로그래밍
- 문자열
- BFS
- Unreal Engine 5
- 구현
- VR
- Team Fortress 2
- 백트래킹
- 자료구조
Archives
- Today
- Total
1일1알
백준 1120번 문자열 C++ 본문
A에만 문자를 추가할 수 있기 때문에 b 안에서 a와 가장 비슷한 문자열을 찾았다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str1, str2;
cin >> str1 >> str2;
int ans = 50;
for (int i = 0; i < str2.length(); i++) {
if (i + str1.length() > str2.length()) break;
int cnt = str1.length();
for (int j = 0; j < str1.length(); j++) {
if (str2[i + j] == str1[j]) cnt--;
}
ans = min(ans, cnt);
}
cout << ans;
};
'알고리즘' 카테고리의 다른 글
백준 2448번 별 찍기 - 11 C++ (0) | 2022.03.27 |
---|---|
백준 4963번 섬의 개수 C++ (0) | 2022.03.26 |
백준 1475번 방 번호 C++ (0) | 2022.03.23 |
백준 6198번 옥상 정원 꾸미기 C++ (0) | 2022.03.21 |
백준 2174번 로봇 시뮬레이션 C++ (0) | 2022.03.20 |