#3780
Maximum Sum of Three Numbers Divisible by Three
medium · 47.7% accepted · 60 likes · top 33%
array · greedy · sorting · heap (priority queue)
Description
You are given an integer array nums.
Your task is to choose exactly three integers from nums such that their sum is divisible by three.
Return the maximum possible sum of such a triplet. If no such triplet exists, return 0.
Solution