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.
Not sure if it is accepted, but I came to the conclusion after thinking about it. I can not break out of the loop because there are still incoming values in the stream, I don't want to roll those over to the next test case.
Basically look at it this way, if your sum is 5 and your array is:
1 4 3 2
I know after 1 and 4 I have my answers, but if I don't do cin for 3 and 2, then breaking out will just take them to the next case.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
Not sure if it is accepted, but I came to the conclusion after thinking about it. I can not break out of the loop because there are still incoming values in the stream, I don't want to roll those over to the next test case. Basically look at it this way, if your sum is 5 and your array is: 1 4 3 2 I know after 1 and 4 I have my answers, but if I don't do cin for 3 and 2, then breaking out will just take them to the next case.