FastPrepMaximum Easy Tasks After Rearranging
Problems/Maximum Easy Tasks After Rearranging

Maximum Easy Tasks After Rearranging

IBM logoIBM● MediumINTERNFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IBM intern or full-time online assessment. Our task, example, function signature and the visible limits are about 99% the same as the reported question.

Special thanks: 🌷 A special thank you to a lovely, amazing fren who shared that this question appeared again on November 5, 2026! ( ˶ˆᗜˆ˵ ) 💜

You are given an integer array taskDifficulty. You may rearrange its elements in any order.

A task is easy when both conditions hold:

  • It has an immediate neighbor on its left and on its right, so the first and last positions cannot be easy.
  • Its difficulty is strictly less than the difficulties of both immediate neighbors.

Return the maximum possible number of easy tasks after rearranging the array.

Function

getMaximumTasks(taskDifficulty: int[]) → int

Examples

Example 1

taskDifficulty = [4,5,6,1,2]return = 2

One optimal order is [4,1,5,2,6]. The values 1 and 2 are each strictly smaller than both immediate neighbors, so two tasks are easy.

Constraints

  • 1 <= taskDifficulty.length <= 2 * 10^5.
  • 1 <= taskDifficulty[i] <= 10^9.

More IBM Online Assessment questions

  • Missing IntervalsOA · Seen Nov 2026
  • Last Object Exit TimeOA · Seen Nov 2026
  • Count Peaks and ValleysOA · Seen Nov 2026
  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
  • Tree Pythagorean TriplesOA · Seen Oct 2026
  • Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
  • Maximum Compatible Time WindowsOA · Seen Oct 2026
  • Query Type Frequency WindowOA · Seen Oct 2026

Similar questions at other companies

  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
  • Minimum Machines for TasksExpedia · OAExpedia interview questions
  • Find Minimum Possible SizeMathWorks · OAMathWorks interview questions
  • Minimum Days to Watch All MoviesAdobe · OAAdobe interview questions
  • Efficient Janitor TripsRoblox · OARoblox interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
  • Minimum Tunnel Crossing TimeArcesium · OAArcesium interview questions
  • Get Maximum PairsAmazon · OA

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int getMaximumTasks(int[] taskDifficulty) {
        // Write your code here
    }
}
Checking account…