PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/MathWorks

How to maximize rewards with exactly k tasks

Last updated: Mar 29, 2026

Quick Overview

This Coding & Algorithms question evaluates a candidate's ability to perform combinatorial optimization and benefit-based assignment reasoning on arrays, testing algorithm design, complexity-aware implementation, and quantitative decision-making in constrained assignment problems.

  • easy
  • MathWorks
  • Coding & Algorithms
  • Software Engineer

How to maximize rewards with exactly k tasks

Company: MathWorks

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are assigning **n** independent tasks to **two interns**. - Each task must be done by exactly one intern. - If intern 1 does task *i*, you earn `reward1[i]` points. - If intern 2 does task *i*, you earn `reward2[i]` points. - Intern 1 must be assigned **exactly `k` tasks**; intern 2 gets the remaining `n - k` tasks. - Tasks can be assigned in any order (no contiguity requirement). **Goal:** Return the **maximum total points** achievable. ### Input - `reward1`: integer array of length `n` - `reward2`: integer array of length `n` - `k`: integer (`0 ≤ k ≤ n`) ### Output - An integer: the maximum possible total reward. ### Notes / Expected Complexity Design an algorithm that works efficiently for large `n` (e.g., up to `10^5`).

Quick Answer: This Coding & Algorithms question evaluates a candidate's ability to perform combinatorial optimization and benefit-based assignment reasoning on arrays, testing algorithm design, complexity-aware implementation, and quantitative decision-making in constrained assignment problems.

Related Interview Questions

  • Minimize shortest path by adding weight-1 edges - MathWorks (easy)
  • Maximize minimum after K decrements - MathWorks (easy)
  • Maximize minimum value after k decrements - MathWorks (medium)
  • Determine Whether P's Position Is Unique - MathWorks (medium)
  • Minimize reduction cost and validate equal-sum pairs - MathWorks (medium)
MathWorks logo
MathWorks
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

You are assigning n independent tasks to two interns.

  • Each task must be done by exactly one intern.
  • If intern 1 does task i , you earn reward1[i] points.
  • If intern 2 does task i , you earn reward2[i] points.
  • Intern 1 must be assigned exactly k tasks ; intern 2 gets the remaining n - k tasks.
  • Tasks can be assigned in any order (no contiguity requirement).

Goal: Return the maximum total points achievable.

Input

  • reward1 : integer array of length n
  • reward2 : integer array of length n
  • k : integer ( 0 ≤ k ≤ n )

Output

  • An integer: the maximum possible total reward.

Notes / Expected Complexity

Design an algorithm that works efficiently for large n (e.g., up to 10^5).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More MathWorks•More Software Engineer•MathWorks Software Engineer•MathWorks Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.