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.
Because i is the index of array, starting from where 3 sides of the triangle can be chosen. The sides are A[i], A[i+1] and A[i+2]. If we take any higher value of i, the index becomes n or higher (because of A[i+2]) which goes out of range.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Perimeter Triangle
You are viewing a single comment's thread. Return to all comments →
Because i is the index of array, starting from where 3 sides of the triangle can be chosen. The sides are A[i], A[i+1] and A[i+2]. If we take any higher value of i, the index becomes
n
or higher (because of A[i+2]) which goes out of range.