BackeasyStack Accenture

Validate Message Timestamps Solution

Problem Statement

Given an array of integers representing message timestamps, determine if the received messages can be sent in the original order. You are given an array of timestamps where each timestamp represents the time a message was received.

Example 1
Input
[1, 2, 3, 4, 5]
Output
true

Explanation: The messages can be sent in the original order

Example 2
Input
[5, 4, 3, 2, 1]
Output
false

Explanation: The messages cannot be sent in the original order

Example 3
Input
[1, 3, 2, 4, 5]
Output
false

Explanation: The messages cannot be sent in the original order

Constraints

  • 1 <= timestamps.length <= 100000
  • -100000 <= timestamps[i] <= 100000
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free