Https://www.codechef.com/viewsolution/37008240

my code works properly for given test cases but when submitted it gives runtime error (NZEC)

Please put the link to your solution in the post body (where we can click on it) instead of the title (where we can’t) :slight_smile:

https://www.codechef.com/viewsolution/37008240

Consider the test input:

1
LLUDLLUD
1 2
2
2 3
1 -2
3 Likes

CodeChef: Practical coding for everyone . your test case helped me to solve the issue but now my code gives TLE the time complexity is O(S + Q) where s is the length of the string and q is the number of queries. can you please help me with this too.

The time limits for this question are very tight, so you need a very well-optimised solution. That means:

  • Very fast input and output
  • Probably not using a Map.
2 Likes

@ssjgz Have a look at this one man : CodeChef: Practical coding for everyone .

Global variables strike again :sob:

2
RLUDRLUD
1 2
2
2 3
1 -2                           
RLUDRLUD
1 2
2
2 3
1 -2
3 Likes

Hhahaaaahahah. Lemme Write str.clear() before taking the input. To be honest, this is only the second time im using globals xD . Thanks for the insight man <3 .

1 Like

i dont need to work on my logic right.

I can’t immediately see anything wrong with the logic.

CodeChef: Practical coding for everyone. I have made the suggested changes in my code but is still gives me tle

No idea then :man_shrugging:

Some of the AC Java solutions are using BufferedWriters.

1 Like