I am given an array of Transactions in a ledger. A Transaction object has three things.
Sender (which means who started this transaction)
Receiver (means who is the destination of transaction)
Timestamp (at what time this transaction was executed)
Now I need to write a method findIfTransactionIsValid() which will have the array of all transactions, one sender, one receiver. A transaction is valid is following cases:
if sender and receiver are same
The timestamp should be increasing (what I mean here is if A -> B happens at Time 2 and B-> C happens at Time 1, then A->C is not a valid transaction, however if B -> C happens at Time 3 then A --> C is a valid transaction)