FastPrepOptimizing Resource Allocation
Problems/Optimizing Resource Allocation

Optimizing Resource Allocation

Dell Technologies logoDell Technologies● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given an array arr of n resources and a number k. A subarray is a group of items that sit next to each other in arr.

Pick a subarray that follows both rules:

  • It has exactly k items.
  • All of its items are different.

Return the largest sum such a subarray can have. If no subarray follows both rules, return -1.

For example, in [1, 2, 3, 7, 3, 5] with k = 3, the subarray [7, 3, 5] has three different items and the largest sum, 15.

Function

findOptimalResources(arr: int[], k: int) → int

Examples

Example 1

arr = [1, 2, 3, 7, 3, 5]k = 3return = 15

These subarrays of length k = 3 have three different items:

  • [1, 2, 3]: 1 + 2 + 3 = 6
  • [2, 3, 7]: 2 + 3 + 7 = 12
  • [7, 3, 5]: 7 + 3 + 5 = 15

[3, 7, 3] does not count, because 3 appears twice. The largest sum is 15.

Constraints

  • 1 ≤ k ≤ arr.length ≤ 10^5
  • 1 ≤ arr[i] ≤ 10^4

More Dell Technologies interview questions

  • Departments Without EmployeesPHONE SCREEN · Seen Oct 2026
  • Find All Pythagorean TripletsPHONE SCREEN · Seen Oct 2026
  • First Non-Repeated CharacterPHONE SCREEN · Seen Oct 2026
  • Count Binary SubstringsOA · Seen May 2025

Similar questions at other companies

  • Maximize Resource AllocationIBM · OAIBM interview questions
  • API Rate Limit Violation DetectionTekion · OATekion interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Count Subarrays with at Least K Equal-Fruit PairsTikTok · OATikTok interview questions
  • Consistent LogsRippling · OARippling interview questions
  • Minimum Length Good SubarrayMicrosoft · OAMicrosoft interview questions
  • Auction Sniping Window MinimumCisco · OACisco interview questions
  • Balanced Prefix Sets in a PermutationUber · OAUber interview questions
  • Shortest Subarray Covering an Integer RangeMarshall Wace · OAMarshall Wace interview questions
All Dell Technologies interview questionsSee Dell Technologies hiring insights
Saved
class Solution {
    public int findOptimalResources(int[] arr, int k) {
      // write your code here
    }

}
Checking account…