[Solved] how to speed up my code?


I wonder what can I do to increase the speed of the code. Can I get rid of some loops etc?

The time complexity of each test case will be O(n) regardless of what you do, since you have to read all the numbers before you know when you stop printing zeros.

Now, as for speeding up, you can indeed remove at least one loop. Hint: you don’t need to count how many zeros there are, only how many ones.

solved how to speed up my code?