ABHISHEK-AMRUTE / CP_Algorithms_hacktoberfest

Collection of All CP algorithms
16 stars 69 forks source link

My solution to a good codechef starter problem- Suspicious String #123

Closed rahulranjan74 closed 1 year ago

rahulranjan74 commented 1 year ago

here is the question link - https://www.codechef.com/START59D/problems/SUSSTR Here is my answer in c++ 17

include

include <bits/stdc++.h>

include

using namespace std;

int main() { // your code goes here int number; cin >> number; for(int i = 0; i < number; i++){ string test; cin >> test;

    string latest = "";
    int x = 0;
    int test_number;
    cin >> test_number;
    int y = test_number-1;
    while(x <= y){
        if(test[x] == '1'){
            latest = latest + test[i];
        }
        else
        latest = test[x] + latest;
        if(x < y){
            if(test[y] == '1'){
                 latest = test[y] + latest;
            }
            else
            latest = latest + test[y];
            y--;
        }
        x++;
    }
    cout << latest << endl;

}

return 0;

}

ABHISHEK-AMRUTE commented 1 year ago

@rahulranjan74 please make a file for your solution in the appropriate folder.

rahulranjan74 commented 1 year ago

@rahulranjan74 please make a file for your solution in the appropriate folder.

okay

rahulranjan74 commented 1 year ago

@ABHISHEK-AMRUTE done, i have uploaded the file, kindly review it and tell if any other steps are required done in a new pull request

ABHISHEK-AMRUTE commented 1 year ago

Closing this PR as changes are covered here https://github.com/ABHISHEK-AMRUTE/CP_Algorithms_hacktoberfest/pull/126