FastPrepStarlight
Problems/Starlight

Starlight

Rubrik logoRubrik● HardOA

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

The beauty of an integer array is the maximum sum of a contiguous subarray. Choosing no elements is allowed, so beauty is never negative.

You may choose one contiguous segment and multiply every value in that segment by z. This amplification may be used at most once.

Return the maximum beauty obtainable after the optional amplification.

Function

enhanceLuminescence(arr: int[], z: int) → long

Examples

Example 1

arr = [3, 2]z = 2return = 10

Amplifying the entire array produces [6, 4], whose sum is 10.

Example 2

arr = [-5, 9, -2, 1, -6]z = -3return = 30

Amplify [-2, 1, -6] to obtain [6, -3, 18]. The best subarray is then [9, 6, -3, 18], with sum 30.

Example 3

arr = [1, 2, 4, 5]z = -2return = 12

Skipping amplification keeps the full-array sum 12, which is optimal.

Constraints

  • 1 <= arr.length <= 2 * 10^5.
  • -10^9 <= arr[i] <= 10^9.
  • -100 <= z <= 100.

More Rubrik interview questions

  • Colored Rooted TreeONSITE INTERVIEW · Seen Nov 2026
  • Delete and Freeze GameOA · Seen Nov 2026
  • Delete K Subsets for Maximum ScoreOA · Seen Nov 2026
  • Distribute Elements Into Two Arrays IIOA · Seen Nov 2026
  • Minimum Replacements to Sort the ArrayOA · Seen Nov 2026
  • All Balanced Strings from Minimum Parenthesis InsertionsONSITE INTERVIEW · Seen Nov 2026
  • Insert into a Left-Complete Binary TreeONSITE INTERVIEW · Seen Oct 2026
  • Thread-Safe Request Counts by AttributeONSITE INTERVIEW · Seen Oct 2026
  • Minimum Swaps To Binary PalindromeOA · Seen Apr 2026
  • Get Minimum OperationsOA · Seen Nov 2024

Similar questions at other companies

  • At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
  • Largest Consistent Visiting GroupAuxoAI · OA
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Maximum Index-Weighted Sum with Disjoint SwapsVisa · OAVisa interview questions
  • Maximum Sum of HeightsVirtu Financial · OAVirtu Financial interview questions
  • Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
  • Get Minimum IncrementIBM · OAIBM interview questions
  • Jump Game with Prime-3 StepsUber · OAUber interview questions
  • Maximum Payout with Context SwitchesPhonePe · OAPhonePe interview questions
  • Maximize Array Beauty After DeletionsPoint72 · OAPoint72 interview questions
All Rubrik interview questionsSee Rubrik hiring insights
Saved
class Solution {
    public long enhanceLuminescence(int[] arr, int z) {
      // write your code here
    }

}
Checking account…