No Strings Attached

Pages: 12
Jul 8, 2018 at 2:01pm
Can anyone help me with this question ?
my approach was to find greatest character from the current char and find their difference but it gave me WA.Can anyone guide me here?

Last edited on Jul 8, 2018 at 2:02pm
Jul 8, 2018 at 6:15pm
Um
*What are you trying to do?
*What don't you understand?
*What have you tried so far?
*Where is your code?

It's hard really, to help you without the above..
Jul 8, 2018 at 6:17pm
Last edited on Jul 8, 2018 at 6:18pm
Jul 9, 2018 at 2:36am
I have replaced the current char by the max char occuring after it and had a count of (curr - max).Heres the problem link

https://www.codechef.com/JULY18B/problems/NSA
Jul 9, 2018 at 1:12pm
Someone please help me with this problem !!
Jul 9, 2018 at 2:52pm
i have partially accepted solution for both NSA and NMNMX.
if anyone has fully accepted solution of any and wants partial of the other , DM me
Jul 11, 2018 at 4:20am
@wasp

why are changing with maximum character occuring.

zzzzzzzzaaab

take this example
Jul 11, 2018 at 5:33am
yes here i change every a to b to the answer is 3
Jul 11, 2018 at 5:41am
Why are you changing all a's?You can only change 1 letter in the entire string...
Jul 11, 2018 at 6:05am
I have come up with an O(n^2logn) approach but its still not good enough for 100pts :/
Jul 11, 2018 at 6:13am
@honeybuzz can you share your algo PM me
Jul 11, 2018 at 8:00am
@gear how can your solution be O(n) if it is brute force?I think you might be messing up the logic to reduce the complexity and hence are getting WA...Because using brute force to simply calculate the cost of the given string without even making any changes itself is O(n^2).
Jul 11, 2018 at 8:20am

@vigilante

In abcd
bcd > a so count 3
then cd > b so count 3+2=5
then c>d so count 5+1=6

Jul 11, 2018 at 9:07am
@Wasp actually my solution is just able to pass 1 test case of the last subtask...Hence even though its better than the brute force(since it passes only 3 cases), my solution passes just 1 more case...Moreover, the 2nd test case of the 2nd subtask still gave TLE...
Jul 11, 2018 at 10:34am

@honeybuzz

what algo u use for clearing last subtask . how u reduce time complexity..
Jul 11, 2018 at 10:45am

@ gear1

ur concept can give maximum value of answer x+y=25 .. thats always not true..
Jul 11, 2018 at 11:46am
u can calculate next max element for every index....that can help
Jul 11, 2018 at 1:02pm
@hackr1
check your pm
Jul 11, 2018 at 1:09pm
@hackr1
now check pm and now make your promise, give me the solution.
and don't worry i will not copy paste the solution .
Jul 11, 2018 at 1:18pm
@hackr1
check you pm
Pages: 12