투 포인터 좋은 예라고 볼 수 있다. 여기서 R의 예외조건에 대해서 알아야하는데 내가 짠 알고리즘에서는 R이 커져버려서 while문에 다시 못들어가는데 있었다. https://www.acmicpc.net/problem/16472 #맞은 풀이 #include using namespace std; int N; string s; map kind; int ans = 0; // 최대 구간 길이 int main() { ios::sync_with_stdio(0); cin.tie(0); cin>>N; cin>>s; int num = 0; // 종류 int L = 0; int R = 0; if(s.size()