Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var map : [String: Int]
- /** Initialize your data structure here. */
- init() {
- map = [String:Int]()
- }
- /** Returns true if the message should be printed in the given timestamp, otherwise returns false.
- If this method returns false, the message will not be printed.
- The timestamp is in seconds granularity. */
- func shouldPrintMessage(_ timestamp: Int, _ message: String) -> Bool {
- if let time = map[message] , timestamp - time < 10 {
- return false
- }
- map[message] = timestamp
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement