Perf-tests 2,3,6,7 failing

My approach is DFS Based. Perf-tests- 2,3,6,7 are failing.
I downloaded the perftest 2 testcase and provided it as a custom testcase, but on running it i am getting TimeoutExpired.

You are running an O(N^2) brute force logic to solve your code. Please optimize your logic to do it in O(N) time.

@omkarlubal Were you able to optimize your code?

no i was doing other problems, will try to solve this one now.
P.s: solved it in 0(n) time.

1 Like

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.