Here in this program i have used Sliding Window, and i got the test case passed, but is this approach wrong? https://ide.codingblocks.com/s/119008
And how can i do it with stacks
Approach in Strongest Fighter
@Kishan-Mishra-2464674013761441
Your code has a complexity of O(nk ) . This problem can be solved using Sliding Window Technique discussed in Deque Section using a deque in O(n) time complexity. Kindly refer to it. While this may have passed the test cases , it is not the optimal solution.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.