1 solutions

  • 0
    @ 2026-11-15 12:24:36

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        char a[10000], chr;
        cin >> n;
        for(int i = 0; i < n; i++)
            cin >> a[i];
        cin >> chr;
        for(int i = 0; i < n; i++)
        {
            if(a[i] == chr)
            {
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
        return 0;
    }
    
    • 1

    Information

    ID
    180
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    2
    Uploaded By