Effective Manager
Updated
Problem statement
A product manager has to organize n meetings with different people. Meeting with each person results in an increase or decrease in the effectiveness index of the manager. The manager wants to organize the meetings such that the index remains positive for as many meetings as possible. Find the maximum number of meetings for which the effectiveness index is positive. The index at the beginning is 0.
Note: After the meetings begin, the index must remain above 0 to be positive.
Function
maxMeetings(effectiveness: int[]) → int
Complete the function maxMeetings in the editor.
maxMeetings has the following parameter:
int effectiveness[n]: the increase or decrease effectiveness for each meeting.
Returns
int: the maximum possible number of meetings while maintaining a positive index
Examples
Example 1
effectiveness = [1, -20, 3, -2]return = 3One optimal meeting order is [3, -2, 1, -20]. The index is positive for the first three meetings, after which it is 3 - 2 + 1 = 1. So, the answer is 3. There is no way to have 4 meetings with a positive index.
Constraints
- 1 <= n <= 10^5
- -10^9 <= effectiveness[i] <= 10^9
More Goldman Sachs interview questions
- House Robber IIIPHONE SCREEN · Seen Nov 2026
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
- Maximum Ones After K OperationsOA · Seen Nov 2026
- Palindrome CounterOA · Seen Oct 2026
- Longest Palindromic SubsequenceOA · Seen Oct 2026
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Maximum ScoreNVIDIA · OANVIDIA interview questions
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
- Minimize the Sum with Ceiling HalvesSquarepoint Capital · OASquarepoint Capital interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Minimize Total Weight After HalvingAmazon · ONSITE INTERVIEW
- Defer Expenses to Preserve BalanceDRW · PHONE SCREENDRW interview questions
- Minimize Array Sum After K Halving OperationsDocuSign · PHONE SCREENDocuSign interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions