Posted on March 7, 2021March 7, 2021 Description Submission class Solution { public: int maxNumberOfApples(vector<int>& arr) { sort(arr.begin(), arr.end()); int ret = 0; int sum = 0; for(int x: arr) { sum += x; if(sum > 5000) return ret; ret++; } return ret; } }; By Bill0412 Easy LeetCode