Amazon Interview Question | Need O(1) Solution
Anonymous User
515

Get a interview question today and never see this in leetcode. Would someone please help?
If this is a leetcode question please let me know and I will update the post:) Thank you.

Given a linked list, a user reads the first message and last message everyday, take them as first and last node then remove them from the list. Each node value represent the working time of the message. The sum of all the node value is the total working time.

Give a O(1) solution to calculate the maximum working time for a day.

Ex.
Input: 1->2->3->5
Output: 6 (1 and 5 is the max working time which makes the maximum working time to be 6)

Input: 1->2->6->5
Output: 8 (the sum of 2 and 6 makes the maximum working time to 8)

Comments (3)