Submission

Status:

[PPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: Krispans

Problemset: สตริงซ้ำซ้ำ

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-24 16:14:34

#include <iostream>
#include <vector>
using namespace std;

int main(){

    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    int n1 = s1.length();
    int n2 = s2.length();
    int max;
    if (n1 > n2){
        string seen ="";
        max = n1;
        for (int i=0; i<max; i++){
            if (seen.find(s1[i]) == string::npos){
                if(s2.find(s1[i]) != string::npos){
                    cout << s1[i] << ' ';
                    seen.push_back(s1[i]);
                }
            }
        }
    }
    else{
        string seen = "";
        max = n2;
        for (int i=0; i<max; i++){
            if (seen.find(s2[i]) == string::npos){
                if(s1.find(s2[i]) != string::npos){
                    cout << s2[i] << ' ';
                    seen.push_back(s2[i]);
                }
            }
        }
    }
    
}