bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1169. Invalid Transactions

1169. Invalid Transactions

Leetcode Solutions

Sorting and Hash Map Approach

  1. Create a list to store invalid transactions.
  2. Sort the transactions by time.
  3. Create a hash map to store transactions by name.
  4. Iterate through the sorted transactions.
  5. For each transaction, split it into name, time, amount, and city.
  6. Check if the amount exceeds $1000, if so, mark it as invalid.
  7. Check the hash map for other transactions with the same name.
  8. If another transaction is within 60 minutes and in a different city, mark both as invalid.
  9. Update the hash map with the current transaction.
  10. Return the list of invalid transactions.
UML Thumbnail

Brute Force Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...