FastPrepSummarize the Latest Event for Each Device
Problems/Summarize the Latest Event for Each Device

Summarize the Latest Event for Each Device

OneTrust logoOneTrust● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a OneTrust phone screen for a full-time role. The report gives the task and the interview setting. We rebuilt the function signature, fixed tie-breaking, the examples, and the limits to stay close to the report.

Our version is about 90% the same as the reported question.

Each device event is [eventId, deviceId, status, timestamp], where the timestamp is a nonnegative decimal integer.

Return one row [deviceId, latestStatus, latestTimestamp, eventCount] per device. Preserve the order in which device IDs first appear. A later input event wins when timestamps tie, and the input must not be mutated.

Function

summarizeByDevice(events: String[][]) → String[][]

Examples

Example 1

events = [["e1","d1","online","10"],["e2","d2","offline","8"],["e3","d1","offline","14"]]return = [["d1","offline","14","2"],["d2","offline","8","1"]]

Device d1 uses its later event and has two total events.

Example 2

events = [["a","x","online","5"],["b","x","offline","5"]]return = [["x","offline","5","2"]]

The later input wins a timestamp tie.

Example 3

events = []return = []

No events produce no summaries.

Constraints

  • 0 <= events.length <= 100000.
  • Status is online or offline.
  • Timestamps fit in a signed 64-bit integer.

More OneTrust interview questions

  • Merge IntervalsPHONE SCREEN · Seen Sep 2026
  • Keep the First Key for Each Distinct ValueONSITE INTERVIEW · Seen Sep 2026
  • Kth Largest Element in an ArrayONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Bounded IPv4 FilterAmazon · PHONE SCREEN
  • SimpleRDD Multiset IntersectionDatologyAI · PHONE SCREEN
  • Vehicle Maintenance Event ReadinessWaymo · PHONE SCREENWaymo interview questions
  • Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
  • Employee Training StatusVanta · PHONE SCREEN
  • Select Object by Key ExtremeBridge · PHONE SCREENBridge interview questions
  • Group Names by DepartmentMastercard · PHONE SCREENMastercard interview questions
  • Badge Records Without a MatchWhatNot · PHONE SCREENWhatNot interview questions
  • AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions
See OneTrust hiring insights
Saved
class Solution {
    public String[][] summarizeByDevice(String[][] events) {
        // write your code here
    }
}
Checking account…