Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5634ac

Browse files
refactor 1348
1 parent4c0f6a9 commite5634ac

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

‎src/main/java/com/fishercoder/solutions/_1348.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,6 @@
66
importjava.util.Map;
77
importjava.util.TreeMap;
88

9-
/**
10-
* 1348. Tweet Counts Per Frequency
11-
*
12-
* Implement the class TweetCounts that supports two methods:
13-
*
14-
* 1. recordTweet(string tweetName, int time)
15-
* Stores the tweetName at the recorded time (in seconds).
16-
* 2. getTweetCountsPerFrequency(string freq, string tweetName, int startTime, int endTime)
17-
* Returns the total number of occurrences for the given tweetName per minute, hour, or day (depending on freq) starting from the startTime (in seconds) and ending at the endTime (in seconds).
18-
* freq is always minute, hour or day, representing the time interval to get the total number of occurrences for the given tweetName.
19-
* The first time interval always starts from the startTime,
20-
* so the time intervals are [startTime, startTime + delta*1>, [startTime + delta*1, startTime + delta*2>, [startTime + delta*2, startTime + delta*3>, ... , [startTime + delta*i, min(startTime + delta*(i+1), endTime + 1)> for some non-negative number i and delta (which depends on freq).
21-
*
22-
* Example:
23-
* Input
24-
* ["TweetCounts","recordTweet","recordTweet","recordTweet","getTweetCountsPerFrequency","getTweetCountsPerFrequency","recordTweet","getTweetCountsPerFrequency"]
25-
* [[],["tweet3",0],["tweet3",60],["tweet3",10],["minute","tweet3",0,59],["minute","tweet3",0,60],["tweet3",120],["hour","tweet3",0,210]]
26-
*
27-
* Output
28-
* [null,null,null,null,[2],[2,1],null,[4]]
29-
*
30-
* Explanation
31-
* TweetCounts tweetCounts = new TweetCounts();
32-
* tweetCounts.recordTweet("tweet3", 0);
33-
* tweetCounts.recordTweet("tweet3", 60);
34-
* tweetCounts.recordTweet("tweet3", 10); // All tweets correspond to "tweet3" with recorded times at 0, 10 and 60.
35-
* tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // return [2]. The frequency is per minute (60 seconds), so there is one interval of time: 1) [0, 60> - > 2 tweets.
36-
* tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // return [2, 1]. The frequency is per minute (60 seconds), so there are two intervals of time: 1) [0, 60> - > 2 tweets, and 2) [60,61> - > 1 tweet.
37-
* tweetCounts.recordTweet("tweet3", 120); // All tweets correspond to "tweet3" with recorded times at 0, 10, 60 and 120.
38-
* tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // return [4]. The frequency is per hour (3600 seconds), so there is one interval of time: 1) [0, 211> - > 4 tweets.
39-
*
40-
* Constraints:
41-
* There will be at most 10000 operations considering both recordTweet and getTweetCountsPerFrequency.
42-
* 0 <= time, startTime, endTime <= 10^9
43-
* 0 <= endTime - startTime <= 10^4
44-
* */
459
publicclass_1348 {
4610
publicstaticclassSolution1 {
4711
publicstaticclassTweetCounts {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp