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.
Jere's code will still work. a > b will be false, but b > c && b > d will be true, so the value of b will be assigned to ans, then returned. We still end up with the 3 that we're looking for.
Most solutions to this problem will work just fine with duplicate values. It doesn't matter which variable the maximum value comes from; all we care about in this context is the value itself.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Functions
You are viewing a single comment's thread. Return to all comments →
Jere's code will still work. a > b will be false, but b > c && b > d will be true, so the value of b will be assigned to ans, then returned. We still end up with the 3 that we're looking for.
Most solutions to this problem will work just fine with duplicate values. It doesn't matter which variable the maximum value comes from; all we care about in this context is the value itself.