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.
I iterate through the sales data array and check if there exists any consecutive pair of years where the sales decrease. If I find such a pair, I have tried modifying one of the elements to make the sales increase. If there are more than one such pairs or if modifying any of the elements does not result in increasing sales, then it is not possible to present the annual sales graph as required
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Impressing the Boss
You are viewing a single comment's thread. Return to all comments →
I iterate through the sales data array and check if there exists any consecutive pair of years where the sales decrease. If I find such a pair, I have tried modifying one of the elements to make the sales increase. If there are more than one such pairs or if modifying any of the elements does not result in increasing sales, then it is not possible to present the annual sales graph as required