Weighted Jobs from an Encoded Test Case
Updated
Problem statement
The whole test case is supplied as one string, encodedCase. Parse its jobs, then select non-overlapping jobs with the greatest total profit. Return that maximum profit, or zero for no jobs.
For this exercise, each record is start,end,profit, and a semicolon separates records. For example, 1,3,50;3,5,40 describes two jobs. Every record is a separate occurrence and may be selected at most once. Input order is arbitrary.
A job occupies the half-open interval from start to end. A job ending exactly when another starts is compatible with it. You may choose no jobs.
This is weighted job scheduling, with the extra difficulty that the whole test case is encoded as a string.
Function
maxEncodedJobProfit(encodedCase: String) → intExamples
Example 1
encodedCase = "1,3,50;2,4,10;3,5,40;4,6,70"return = 120Select the job from time 1 to 3 with profit 50 and the job from time 4 to 6 with profit 70. They do not overlap, and their total of 120 exceeds the first-and-third total of 90.
Example 2
encodedCase = "0,10,20;1,9,50;2,8,30"return = 50All three intervals overlap. Select the single job with profit 50.
Constraints
- For this exercise, assume
0 <= encodedCase.length <= 6000and at most200records. - Each nonempty record has exactly
start,end,profit, using canonical nonnegative decimal integers, no spaces or leading zeros except the integer 0. Records are separated by one semicolon, with no leading or trailing separator. 0 <= start < end <= 1000000and0 <= profit <= 10000.- The empty string encodes zero jobs.
More JP Morgan Chase Online Assessment questions
- Find Total CostOA · Seen Oct 2026
- Minimum Meeting RoomsOA · Seen Oct 2026
- Count Dropped RequestsOA · Seen Oct 2026
- Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
- Task SchedulingOA · Seen Oct 2026
- Substring RemovalOA · Seen Oct 2026
- Maximum Game Board ScoreOA · Seen Sep 2026
- Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
- Same Substring Within BudgetOA · Seen Sep 2026
- Invert Ad Visibility BitsOA · Seen Aug 2026
Similar questions at other companies
- Fill a Time Window with SongsMicrosoft · OAMicrosoft interview questions
- Maximum Taxi EarningsWells Fargo · OAWells Fargo interview questions
- Maximum Total Length of Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Maximum Highway Billboard RevenueExpedia · ONSITE INTERVIEWExpedia interview questions
- Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
- Maximum Profit in Job SchedulingAmazon · PHONE SCREEN
- Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
- Maximum Event Value with an Attendance LimitSnowflake · PHONE SCREENSnowflake interview questions
- Find Minimum TimeAlphaSense · OA
- Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
Interview reports that mention this question
JP Morgan Chase interview experiences
- JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
- JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
- JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
- JP Morgan Chase Data and AI Intern Superday: 11 Experiences
- JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)