FastPrepSum of On Switch Indices
Problems/Sum of On Switch Indices

Sum of On Switch Indices

Atlassian logoAtlassian● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Atlassian full-time online assessment. The picture in the report gives the full toggle rule and an example. We chose the function name and the numeric limits. Our version is about 98% the same as the reported question.

Switches are numbered with positive consecutive indices and initially are off. Each operation [left, right] toggles every switch in that inclusive interval.

After every operation has been applied, return the sum of the indices of all switches that are on.

Function

sumOnSwitchIndices(operations: int[][]) → long

Examples

Example 1

operations = [[1,4],[2,6],[1,6]]return = 9

Only switches 2, 3, and 4 finish on, so the sum is 9.

Constraints

  • 1 <= operations.length <= 200000
  • 1 <= left <= right <= 10^9
  • The answer fits a signed long.

More Atlassian Online Assessment questions

  • Planning ProductionOA · Seen Feb 2025
  • K-Means ClusteringOA · Seen Feb 2025
  • Minimum Sorted Erasure OperationsOA · Seen Jun 2024
  • Count Analogous ArraysOA · Seen Mar 2024
  • Get Maximum ScoreOA · Seen Mar 2024
  • Better Compression 🦀OA · Seen Mar 2024
  • Romanizer 🐡OA · Seen Mar 2024
  • Flower Bouquets 💐OA · Seen Mar 2024
  • Binary Search Tree IteratorOA · Seen Nov 2023
  • Binary Tree Level Order TraversalOA · Seen Nov 2023

Similar questions at other companies

  • Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
  • Sliding-Window Means with IEEE Special ValuesHeadlands Technologies · OAHeadlands Technologies interview questions
  • Last Object to Fall Off the TableConfluent · OAConfluent interview questions
  • Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Earliest Meeting Time for All EmployeesCapital One · OACapital One interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
  • Earliest Meeting Start on a 24-Hour ClockIMC Trading · OAIMC Trading interview questions
  • Largest Team Where Every Pair OverlapsWalmart · OAWalmart interview questions

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
class Solution {
    public long sumOnSwitchIndices(int[][] operations) {
      // Write your code here.
    }

}
Checking account…