pos is deciding factor that says whether to include non-contributing characters from ‘a’ to p[0] should append at the start of p OR not.refer above editorial twice-thrice (That’s how I understand
most of the time)
Hey i m getting 7/10 test cases passed on codechef
I am definitely missing a corner case
here is the link of my submissionmy_submission
@rishup_nitdgp @admin
pls help i m stuck badly
@anon20008309
your solution is similar to the solution which leak out in python…
and you are posting your solution in editorial
check this
@anon20008309 solution
https://www.codechef.com/viewsolution/36408808
other solution
https://www.codechef.com/viewsolution/36857962
https://www.codechef.com/viewsolution/36857738
and many more…
now i am reporting this to help@codechef.com
This solution will not actually work. It will get TLE because your time complexity is O(n^2).
This is because you are using the python “remove” function which takes O(n) time. And you are using this function inside a for loop which also iterates n times.
Bro, if it was not working then why would I posted the solution here?
Just chill. It works just fine. 
Yes, exactly I was so shocked to see how it’s so similar 
I am not used to code in python. So I can just suggest that you can try to optimize your code.
Like even without sorting you can solve this question.
Try this test case:
1
aaabbbdddd
ddab
Your Output: aabbddddab
Correct Output : aabbddabdd
Also, print the answer to each test case in the newline.
You can check my solution : CodeChef: Practical coding for everyone
thanks bro
Problem statement: CodeChef: Practical coding for everyone Can anyone tell me what’s wrong with my code I got a wrong answer during the competition… CodeChef: Practical coding for everyone
what logic you have used in test case 1 & 2?
output should be
tyzzze
and acddeeeeaghfa
what is wrong with this solution CodeChef: Practical coding for everyone ?
I have tried all the test cases given in the discussions and the solution works perfectly for each one of them please have a look at it.
Why the approach of sorting the string containing the characters other than the patter and sorting it and then append the pattern at the place after the next smallest character of the pattern’s beginning is not working.
#include
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define tiii tuple<int, int, int>
#define pll pair<long long, long long>
#define sii set
#define sll set
#define vii vector
#define vll vector
#define vll vector
#define mii map<int, int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (auto it = a; it != b; it++)
#define ff first
#define all(v) v.begin(), v.end()
#define ss second
#define rep(i, n) for (i = 0; i < n; i++)
#define fu(i, a, n) for (i = a; i <= n; i++)
#define fd(i, n, a) for (i = n; i >= a; i–)
#define gi(n) scanf(% d, &n)
int main()
{
ll t;
cin >> t;
while (t–)
{
string s;
cin >> s;
map<char, ll> m;
ll i;
ll n = s.length();
string match;
cin >> match;
rep(i, n) m[s[i]]++;
rep(i, match.length())
m[match[i]]–;
string ans = “”;
// ans += match;
auto it = m.begin();
for (; it != m.end(); it++)
{
ll j;
for (j = 0; j < it->second; j++)
{
ans += it->first;
}
}
string temp = “”;
ll pos = (lower_bound(all(ans), match[0]) - ans.begin());
for (i = 0; i < pos; i++)
{
temp += ans[i];
}
temp += match;
for (i = pos ; i < ans.length(); i++)
{
temp += ans[i];
}
ans += match;
cout << temp << endl;
}
}
Continuing the discussion from SKMP - Editorial:
can anyone suggest me why it is giving wa
https://www.codechef.com/viewsolution/55771395