Submission

Status:
[PPPPPPPP]

Score: 100

User: sorawit

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

Language: cpp

Time: 0.003 second

Submitted On: 2025-01-19 00:42:55

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;

    bool printed[256] = {false};  // Track printed characters (ASCII size)

    for (int i = 0; i < s1.size(); i++) {
        for (int j = 0; j < s2.size(); j++) {
            if (s2[j] == s1[i] && !printed[s2[j]]) {
                cout << s2[j] << " ";
                printed[s2[j]] = true;
            }
        }
    }

    return 0;
}