We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Its because for every test case we need neg to get initialized since the loop of a0 variable runs for t no. of test cases neg needs to be initialized for every test case. If we initialize it at the beginning it will be initialized only once...hence giving wrong output.
Reading the question and going through my code will clarify your doubt even more now :
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Angry Professor
You are viewing a single comment's thread. Return to all comments →
Its because for every test case we need neg to get initialized since the loop of a0 variable runs for t no. of test cases neg needs to be initialized for every test case. If we initialize it at the beginning it will be initialized only once...hence giving wrong output. Reading the question and going through my code will clarify your doubt even more now :