Need to make code faster

I'm trying to solve the Hackerrank challenge of Super Functional Strings. My code passes through test 4 then times out. All the tests need to run in <= 2 seconds. My code for test test 6, for example, runs in 19 seconds. I've tried many different code configurations (using various data structures) to optimize the code, and what I have now is the best I've come up with. The code includes commented code you can uncomment to benchmark the code. Any General advice on how to make code changes, or try a different overall approach to solving the problem, would be greatly appreciated. Thanks in advance for any replies. My code is at http://ideone.com/9f13QC
long cum[MAX];

What does the word "cum" mean?

You have a working program now, you need to find a way to optimize it correct?
Last edited on
Topic archived. No new replies allowed.