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.
Hm... You are right. Obviously my implementation gives 3 5 (4 + 2) because I move from opposit directions through sorted array, so my algorithm first meets solution with most different numbers. Though, test case is not good enough cause it allows ambiguity. If you replace every "3" in last line by (lets say) "7", "3 5 (4 + 2)" would be still the right answer, and the only one.
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 →
Hm... You are right. Obviously my implementation gives 3 5 (4 + 2) because I move from opposit directions through sorted array, so my algorithm first meets solution with most different numbers. Though, test case is not good enough cause it allows ambiguity. If you replace every "3" in last line by (lets say) "7", "3 5 (4 + 2)" would be still the right answer, and the only one.