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.
can anyone explain how is tis logic working as i am having trouble since n is fixed to 4. In for loop i<2 so i will start from 0 but effetive i in the loop for ++i will be 1 and 2 which the function swap a[1] to a[2] and do the same when i=2 so it is just reversing its impact. whereas when i run this solution and it has successfully completed all test case
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays - DS
You are viewing a single comment's thread. Return to all comments →
can anyone explain how is tis logic working as i am having trouble since n is fixed to 4. In for loop i<2 so i will start from 0 but effetive i in the loop for ++i will be 1 and 2 which the function swap a[1] to a[2] and do the same when i=2 so it is just reversing its impact. whereas when i run this solution and it has successfully completed all test case