Temporal Anomalies
Updated
Problem statement
Each temporal anomaly is represented by four integers [x, y, z, severity].
An anomaly i dominates an anomaly j when all three coordinates of i are greater than or equal to the corresponding coordinates of j:
xi >= xjyi >= yjzi >= zj
For every anomaly, compute the sum of the severities of all anomalies it dominates. An anomaly dominates itself. Anomalies with identical coordinates dominate one another.
Return the scores in the same order as the input rows.
Function
calculateAnomalyScores(anomalies: int[][]) → long[]Examples
Example 1
anomalies = [[1,1,1,5],[2,2,2,10],[1,3,2,4],[3,1,1,2]]return = [5,15,9,7]The second anomaly dominates itself and the first anomaly, giving 10 + 5 = 15. The third and fourth anomalies each dominate the first anomaly in addition to themselves.
Example 2
anomalies = [[2,2,2,3],[2,2,2,7],[1,2,2,5],[3,1,3,4]]return = [15,15,5,4]The first two anomalies have equal coordinates, so each dominates both of them and the third anomaly. Their common score is 3 + 7 + 5 = 15.
Example 3
anomalies = [[1,5,1,2],[1,3,2,4],[1,5,3,8],[2,4,3,16]]return = [2,4,14,20]The third anomaly dominates the first two and itself, for a score of 14. The fourth dominates the second and itself, for a score of 20; the other rows are incomparable with it in at least one coordinate.
Constraints
1 <= anomalies.length <= 100000anomalies[i].length == 41 <= anomalies[i][0], anomalies[i][1], anomalies[i][2] <= 1000001 <= anomalies[i][3] <= 10000
More InMobi Online Assessment questions
- Validate a Bracket SequenceOA · Seen Oct 2026
- Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
- Maximum Subarray with Start and End WindowsOA · Seen Oct 2026
- Minimum Service Cold StartsOA · Seen Oct 2026
- Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
- Connected Components with Divisor ThresholdOA · Seen Aug 2026
- Maximize Impression ValueOA · Seen Aug 2026
- Supply Path OptimizationOA · Seen Aug 2026
- Delivery ServiceOA · Seen Jun 2026
- Shared InterestOA · Seen Jun 2026
Similar questions at other companies
- Minimum Cost to Make Array EqualWalmart · OAWalmart interview questions
- Minimum Euclidean Distance Between PointsLuma AI · OALuma AI interview questions
- Decision Tree Regression from ScratchNVIDIA · OANVIDIA interview questions
- Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
- Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
- Minimum Seats for One-Way Car PoolingSquadStack.ai · OA
- Choose ContainersIMC Trading · OAIMC Trading interview questions
- Find Number of Ways to Split ArrayGoogle · OAGoogle interview questions
- Find Network CallsAmazon · OA
- Count InversionsExpedia · OAExpedia interview questions