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.
why do we need to check, whether i==j in case of diff>k? j is always higher than i and once you find diff>k your i increases, however even though at that stage i=j the for loop already compensates for ++j.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
why do we need to check, whether i==j in case of diff>k? j is always higher than i and once you find diff>k your i increases, however even though at that stage i=j the for loop already compensates for ++j.