Written O(n) solution but still getting time limit exceeded in test case 1. Rest all are working fine. Tried for taking n = 1 edge case but then the test 4 was failing. Please check. It’s not even showing the particular submission in submissions.
Getting time limit exceeded on test case 1
i am pretty sure that you must be using cin and cout for input and output ,Since the input is very large reading input with cin is an overhead try using scanf and printf as it is faster than cin and cout your code would get submitted . On an off chance if it does’nt ,do ask along with your code