zak.abhishek
BAN USER- 0of 0 votes
Answers// Imagine you have an array of N messages which is consistently having new messages added to it.
- zak.abhishek in United States
// When you loop through the array, the messages are guaranteed to be ordered chronologically by timestamp.
// Write some code that loops through the array of messages and when a unique user_id has two messages within one second of each other, call a method too_fast that takes in two parameters, the first is the older message, the second is the newer message.
// In the message examples below we would expect to call the too_fast method with the first and third message, and then again with the third and fifth message.
// message example 1 = { "container_id": 123, "item_id": 456, "success": true, "timestamp": 1499351653, "user_id": 789 }
// message example 2 = { "container_id": 111, "item_id": 222, "success": false, "timestamp": 1499351654, "user_id": 333 }
// message example 3 = { "container_id": 444, "item_id": 555, "success": true, "timestamp": 1499351654, "user_id": 789 }
// message example 4 = { "container_id": 123, "item_id": 456, "success": true, "timestamp": 1499351655, "user_id": 999 }
// message example 5 = { "container_id": 123, "item_id": 456, "success": true, "timestamp": 1499351655, "user_id": 789 }
// Within the loop you can access attributes by using message.getContainerId() or message.getItemId for example, message.getTimestamp()| Report Duplicate | Flag | PURGE
Amazon